[dm-devel] [PATCH v2 11/21] multipath: remove pointless code from getopt processing

mwilck at suse.com mwilck at suse.com
Wed Dec 1 12:36:40 UTC 2021


From: Martin Wilck <mwilck at suse.com>

getopt() never returns 1, and sizeof(optarg) is always sizeof(char *).

Reviewed-by: Benjamin Marzinski <bmarzins at redhat.com>
Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 multipath/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/multipath/main.c b/multipath/main.c
index 2a42748..5711acf 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -841,11 +841,8 @@ main (int argc, char *argv[])
 		condlog(1, "failed to register cleanup handler for vecs: %m");
 	while ((arg = getopt(argc, argv, ":adDcChl::eFfM:v:p:b:BrR:itTquUwW")) != EOF ) {
 		switch(arg) {
-		case 1: printf("optarg : %s\n",optarg);
-			break;
 		case 'v':
-			if (sizeof(optarg) > sizeof(char *) ||
-			    !isdigit(optarg[0])) {
+			if (!isdigit(optarg[0])) {
 				usage (argv[0]);
 				exit(RTVL_FAIL);
 			}
-- 
2.33.1





More information about the dm-devel mailing list