svn commit: r317293 - head/tools/regression/geom_gpt

Ngie Cooper ngie at FreeBSD.org
Sat Apr 22 20:27:47 UTC 2017


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;


More information about the svn-src-head mailing list