[DRBD-cvs] user by lars; fix for eating more than existing argume...

drbd-user@lists.linbit.com drbd-user@lists.linbit.com
Thu, 11 Mar 2004 00:54:45 +0100 (CET)


DRBD CVS committal

Author  : lars
Project : drbd
Module  : user

Dir     : drbd/user


Modified Files:
      Tag: rel-0_7-branch
	drbdsetup.c 


Log Message:
fix for eating more than existing arguments

In an attempt to clean up the drbdsetup.c code,
an important "exit(20);" statement was removed,
without notice.
Added it again.

	lge

===================================================================
RCS file: /var/lib/cvs/drbd/drbd/user/drbdsetup.c,v
retrieving revision 1.54.2.26
retrieving revision 1.54.2.27
diff -u -3 -r1.54.2.26 -r1.54.2.27
--- drbdsetup.c	6 Mar 2004 08:45:28 -0000	1.54.2.26
+++ drbdsetup.c	10 Mar 2004 23:54:40 -0000	1.54.2.27
@@ -70,8 +70,8 @@
 # define ioctl(X...) (fprintf(stderr,"ioctl(%s)\n",#X),0);
 # define PRINT_ARGV do { \
 	int i; \
-		fprintf(stderr,"# argv (optind=%i) in %s:%i:\n#",\
-			optind, __FUNCTION__,__LINE__); \
+		fprintf(stderr,"# argv (optind=%i argc=%i) in %s:%i:\n#",\
+			optind, argc, __FUNCTION__, __LINE__); \
 		for (i=optind; i < argc; i++) \
 			fprintf(stderr," %s",argv[i]); \
 				fprintf(stderr,"\n"); \
@@ -325,6 +325,10 @@
   }
   line[col]=0;
   printf("%s\n",line);
+  if (addinfo) {
+      printf("%s\n",addinfo);
+      exit(20);
+  }
 }
 
 void print_usage(const char* addinfo)
@@ -421,10 +425,10 @@
 	    }
 	  }
 	  fprintf(stderr,"%s: '%s' is an invalid on-io-error handler.\n",
-		  argv[0],optarg);
+		  basename,optarg);
 	  return 20;
 	case 1:	// non option argument. see getopt_long(3)
-	  fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",argv[0],optarg);
+	  fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",basename,optarg);
 	case '?':
 	  return 20;
 	}
@@ -475,7 +479,7 @@
 	  cn->config.sndbuf_size = m_strtol(optarg,1);
 	  break;
 	case 1:	// non option argument. see getopt_long(3)
-	  fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",argv[0],optarg);
+	  fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",basename,optarg);
 	case '?':
 	  return 20;
 	}
@@ -703,7 +707,7 @@
 	      newstate |= TimeoutExpired;
 	      break;
 	    case 1:	// non option argument. see getopt_long(3)
-	      fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",argv[0],optarg);
+	      fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",basename,optarg);
 	    case '?':
 	      return 20;
 	    }
@@ -745,7 +749,7 @@
 	      p.degr_wfc_timeout = m_strtol(optarg,1);
 	      break;
 	    case 1:	// non option argument. see getopt_long(3)
-	      fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",argv[0],optarg);
+	      fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",basename,optarg);
 	    case '?':
 	      return 20;
 	    }
@@ -822,7 +826,7 @@
 	      cn.config.al_extents=m_strtol(optarg,1);
 	      break;
 	    case 1:	// non option argument. see getopt_long(3)
-	      fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",argv[0],optarg);
+	      fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",basename,optarg);
 	    case '?':
 	      return 20;
 	    }
@@ -969,7 +973,7 @@
 	      u_size=m_strtol(optarg,1024);
 	      break;
 	    case 1:	// non option argument. see getopt_long(3)
-	      fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",argv[0],optarg);
+	      fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",basename,optarg);
 	    case '?':
 	      return 20;
 	    }