Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Apr 2017 20:27:46 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317293 - head/tools/regression/geom_gpt
Message-ID:  <201704222027.v3MKRkNI072521@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat Apr 22 20:27:46 2017
New Revision: 317293
URL: https://svnweb.freebsd.org/changeset/base/317293

Log:
  gctl_test_helper: apply polish
  
  - Staticize variables to fix warnings.
  - Sprinkle asserts around for calls that can fail
  - Apply style(9) for main(..) definition.
  - ANSIify usage(..) definition.
  
  MFC after:	5 weeks
  Sponsored by:	Dell EMC Isilon

Modified:
  head/tools/regression/geom_gpt/gctl_test_helper.c

Modified: head/tools/regression/geom_gpt/gctl_test_helper.c
==============================================================================
--- head/tools/regression/geom_gpt/gctl_test_helper.c	Sat Apr 22 20:15:47 2017	(r317292)
+++ head/tools/regression/geom_gpt/gctl_test_helper.c	Sat Apr 22 20:27:46 2017	(r317293)
@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <assert.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>
@@ -42,11 +43,11 @@ struct retval {
 	char *value;
 };
 
-struct retval *retval;
-int verbose;
+static struct retval *retval;
+static int verbose;
 
 static void
-usage()
+usage(void)
 {
 	fprintf(stdout, "usage: %s [-v] param[:len][=value] ...\n",
 	    getprogname());
@@ -105,7 +106,8 @@ parse(char *arg, char **param, char **va
 	return (0);
 }
 
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
 	struct retval *rv;
 	struct gctl_req *req;
@@ -114,6 +116,7 @@ int main(int argc, char *argv[])
 	int c, len;
 
 	req = gctl_get_handle();
+	assert(req != NULL);
 	gctl_ro_param(req, "class", -1, "GPT");
 
 	while ((c = getopt(argc, argv, "v")) != -1) {
@@ -133,6 +136,7 @@ int main(int argc, char *argv[])
 		if (!parse(argv[optind++], &param, &value, &len)) {
 			if (len > 0) {
 				rv = malloc(sizeof(struct retval));
+				assert(rv != NULL);
 				rv->param = param;
 				rv->value = value;
 				rv->retval = retval;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704222027.v3MKRkNI072521>