[hackers] [ubase][PATCH 1/5] mount: Use ternary operators

From: Klemens Nanni <kl3_AT_posteo.org>
Date: Mon, 11 Jul 2016 14:27:56 +0200

---
 mount.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/mount.c b/mount.c
index 2eb175c..e70c7d1 100644
--- a/mount.c
+++ b/mount.c
_AT_@ -64,10 +64,7 @@ parseopts(const char *popts, unsigned long *flags, char *data, size_t datasiz)
 	name = popts;
 	data[0] = '\0';
 	do {
-		if ((e = strstr(name, ",")))
-			optlen = e - name;
-		else
-			optlen = strlen(name);
+		optlen = (e = strstr(name, ",")) ? (size_t)(e - name) : strlen(name);
 
 		validopt = 0;
 		for (i = 0; optnames[i].opt; i++) {
_AT_@ -123,12 +120,8 @@ mounthelper(const char *fsname, const char *dir, const char *fstype)
 		if (argflags & MS_REC)
 			eargv[i++] = "-R";
 
-		if (fsopts[0]) {
-			eargv[i++] = "-o";
-			eargv[i++] = fsopts;
-		}
-		eargv[i++] = fsname;
-		eargv[i++] = dir;
+		eargv[i++] = fsopts[0] ? "-o"   : fsname;
+		eargv[i++] = fsopts[0] ? fsopts : dir;
 		eargv[i] = NULL;
 
 		execvp(eprog, (char * const *)eargv);
-- 
2.8.3
Received on Mon Jul 11 2016 - 14:27:56 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 11 2016 - 14:36:22 CEST