about summary refs log tree commit diff
path: root/src/misc
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-01-21 13:28:40 -0500
committerRich Felker <dalias@aerifal.cx>2015-01-21 13:28:40 -0500
commit63cac4e29a61487423f63bed9150aa9aec906823 (patch)
tree0601666e509b63fc9a4b632106eed52cb7c5c6a3 /src/misc
parente8e4e56a8ce1f3d7e4a027ff5478f2f8ea70c46b (diff)
downloadmusl-63cac4e29a61487423f63bed9150aa9aec906823.tar.gz
musl-63cac4e29a61487423f63bed9150aa9aec906823.tar.xz
musl-63cac4e29a61487423f63bed9150aa9aec906823.zip
simplify part of getopt_long
as a result of commit e8e4e56a8ce1f3d7e4a027ff5478f2f8ea70c46b,
the later code path for setting optarg to a null pointer is no longer
necessary, and removing it eliminates an indention level and arguably
makes the code more readable.
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/getopt_long.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/misc/getopt_long.c b/src/misc/getopt_long.c
index bee77f43..480c0013 100644
--- a/src/misc/getopt_long.c
+++ b/src/misc/getopt_long.c
@@ -87,19 +87,17 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
 					return '?';
 				}
 				optarg = opt+1;
-			} else {
-				if (longopts[i].has_arg == required_argument) {
-					if (!(optarg = argv[optind])) {
-						if (colon) return ':';
-						if (!opterr) return '?';
-						__getopt_msg(argv[0],
-							": option requires an argument: ",
-							longopts[i].name,
-							strlen(longopts[i].name));
-						return '?';
-					}
-					optind++;
-				} else optarg = NULL;
+			} else if (longopts[i].has_arg == required_argument) {
+				if (!(optarg = argv[optind])) {
+					if (colon) return ':';
+					if (!opterr) return '?';
+					__getopt_msg(argv[0],
+						": option requires an argument: ",
+						longopts[i].name,
+						strlen(longopts[i].name));
+					return '?';
+				}
+				optind++;
 			}
 			if (idx) *idx = i;
 			if (longopts[i].flag) {