[stgt] [PATCH 1/4] style fixes in tgtd.c

nezhinsky at gmail.com nezhinsky at gmail.com
Wed Aug 8 09:03:21 CEST 2012


From: Alexander Nezhinsky <nezhinsky at gmail.com>


Signed-off-by: Alexander Nezhinsky <alexandern at mellanox.com>
---
 usr/tgtd.c |   53 +++++++++++++++++++++++++++++------------------------
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/usr/tgtd.c b/usr/tgtd.c
index 6199926..5abf22a 100644
--- a/usr/tgtd.c
+++ b/usr/tgtd.c
@@ -46,12 +46,11 @@ unsigned long pagesize, pageshift;
 
 int system_active = 1;
 static int ep_fd;
-static char program_name[] = "tgtd";
+static char const program_name[] = "tgtd";
 static LIST_HEAD(tgt_events_list);
 static LIST_HEAD(tgt_sched_events_list);
 
-static struct option const long_options[] =
-{
+static struct option const long_options[] = {
 	{"foreground", no_argument, 0, 'f'},
 	{"control-port", required_argument, 0, 'C'},
 	{"nr_iothreads", required_argument, 0, 't'},
@@ -66,29 +65,32 @@ static char *spare_args;
 
 static void usage(int status)
 {
-	if (status)
-		fprintf(stderr, "Try `%s --help' for more information.\n", program_name);
-	else {
-		printf("Usage: %s [OPTION]\n", program_name);
-		printf("\
-Target framework daemon, version %s\n\
-  -f, --foreground        make the program run in the foreground\n\
-  -C, --control-port NNNN use port NNNN for the mgmt channel\n\
-  -t, --nr_iothreads NNNN specify the number of I/O threads\n\
-  -d, --debug debuglevel  print debugging information\n\
-  -V, --version           print version and exit\n\
-  -h, --help              display this help and exit\n\
-", TGT_VERSION);
+	if (status) {
+		fprintf(stderr, "Try `%s --help' for more information.\n",
+			program_name);
+		exit(status);
 	}
-	exit(status);
+
+	printf("Linux SCSI Target framework daemon, version %s\n\n"
+		"Usage: %s [OPTION]\n"
+		"-f, --foreground        make the program run in the foreground\n"
+		"-C, --control-port NNNN use port NNNN for the mgmt channel\n"
+		"-t, --nr_iothreads NNNN specify the number of I/O threads\n"
+		"-d, --debug debuglevel  print debugging information\n"
+		"-V, --version           print version and exit\n"
+		"-h, --help              display this help and exit\n",
+		TGT_VERSION, program_name);
+	exit(0);
 }
 
 static void bad_optarg(int ret, int ch, char *optarg)
 {
 	if (ret == ERANGE)
-		fprintf(stderr, "-%c argument value '%s' out of range\n", ch, optarg);
+		fprintf(stderr, "-%c argument value '%s' out of range\n",
+			ch, optarg);
 	else
-		fprintf(stderr, "-%c argument value '%s' invalid\n", ch, optarg);
+		fprintf(stderr, "-%c argument value '%s' invalid\n",
+			ch, optarg);
 	usage(ret);
 }
 
@@ -99,9 +101,10 @@ static void version(void)
 }
 
 /* Default TGT mgmt port */
-short int control_port = 0;
+short int control_port;
 
-static void signal_catch(int signo) {
+static void signal_catch(int signo)
+{
 }
 
 static int oom_adjust(void)
@@ -113,12 +116,14 @@ static int oom_adjust(void)
 	sprintf(path, "/proc/%d/oom_adj", getpid());
 	fd = open(path, O_WRONLY);
 	if (fd < 0) {
-		fprintf(stderr, "can't adjust oom-killer's pardon %s, %m\n", path);
+		fprintf(stderr, "can't adjust oom-killer's pardon %s, %m\n",
+			path);
 		return errno;
 	}
 	err = write(fd, "-17\n", 4);
 	if (err < 0) {
-		fprintf(stderr, "can't adjust oom-killer's pardon %s, %m\n", path);
+		fprintf(stderr, "can't adjust oom-killer's pardon %s, %m\n",
+			path);
 		close(fd);
 		return errno;
 	}
@@ -565,7 +570,7 @@ int main(int argc, char **argv)
 	if (err)
 		exit(1);
 
-	if (is_daemon && daemon(0,0))
+	if (is_daemon && daemon(0, 0))
 		exit(1);
 
 	err = log_init(program_name, LOG_SPACE_SIZE, is_daemon, is_debug);
-- 
1.7.9.6

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list