[lttng-dev] [PATCH lttng-tools 05/13] Missing error handling: consumerd parse_args should return errors to caller

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Wed Dec 17 20:45:16 EST 2014


In preparation for having main() handle the return value.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/bin/lttng-consumerd/lttng-consumerd.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c
index 299776a..ceb1da4 100644
--- a/src/bin/lttng-consumerd/lttng-consumerd.c
+++ b/src/bin/lttng-consumerd/lttng-consumerd.c
@@ -186,9 +186,9 @@ static void usage(FILE *fp)
 /*
  * daemon argument parsing
  */
-static void parse_args(int argc, char **argv)
+static int parse_args(int argc, char **argv)
 {
-	int c;
+	int c, ret = 0;
 
 	static struct option long_options[] = {
 		{ "consumerd-cmd-sock", 1, 0, 'c' },
@@ -218,6 +218,8 @@ static void parse_args(int argc, char **argv)
 			fprintf(stderr, "option %s", long_options[option_index].name);
 			if (optarg) {
 				fprintf(stderr, " with arg %s\n", optarg);
+				ret = -1;
+				goto end;
 			}
 			break;
 		case 'c':
@@ -260,9 +262,12 @@ static void parse_args(int argc, char **argv)
 #endif
 		default:
 			usage(stderr);
-			exit(EXIT_FAILURE);
+			ret = -1;
+			goto end;
 		}
 	}
+end:
+	return ret;
 }
 
 /*
-- 
2.1.1




More information about the lttng-dev mailing list