DragonFly BSD
DragonFly submit List (threaded) for 2005-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

warns+style patch for ktrace


From: Haakon Schad Bergsaker <hakonsb@xxxxxxxxxxx>
Date: Sat, 9 Apr 2005 12:21:15 +0200 (CEST)

Attached is a patch to make usr.bin/ktrace WARNS=6 and style(9) clean.

-- 
Haakon Schad Bergsaker
Index: Makefile
===================================================================
RCS file: /home/dcvs/src/usr.bin/ktrace/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- Makefile	17 Jun 2003 04:29:27 -0000	1.2
+++ Makefile	9 Apr 2005 11:27:02 -0000
@@ -5,5 +5,6 @@
 PROG=	ktrace
 SRCS=	ktrace.c subr.c
 MLINKS= ktrace.1 trace.1 
+WARNS?= 6
 
 .include <bsd.prog.mk>
Index: ktrace.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/ktrace/ktrace.c,v
retrieving revision 1.3
diff -u -r1.3 ktrace.c
--- ktrace.c	4 Oct 2003 20:36:46 -0000	1.3
+++ ktrace.c	9 Apr 2005 12:12:43 -0000
@@ -46,27 +46,30 @@
 
 #include <err.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include "ktrace.h"
 
-void no_ktrace(int);
-void usage(void);
+static void no_ktrace(int);
+static void usage(void);
+static int rpid(char *p);
 
+int
 main(int argc, char **argv)
 {
 	enum { NOTSET, CLEAR, CLEARALL } clear;
 	int append, ch, fd, inherit, ops, pid, pidset, trpoints;
-	char *tracefile;
+	const char *tracefile;
 	mode_t omask;
 	struct stat sb;
 
 	clear = NOTSET;
-	append = ops = pidset = inherit = 0;
+	append = ops = pid = pidset = inherit = 0;
 	trpoints = DEF_POINTS;
 	tracefile = DEF_TRACEFILE;
-	while ((ch = getopt(argc,argv,"aCcdf:g:ip:t:")) != -1)
-		switch((char)ch) {
+	while ((ch = getopt(argc, argv, "aCcdf:g:ip:t:")) != -1)
+		switch (ch) {
 		case 'a':
 			append = 1;
 			break;
@@ -107,13 +110,13 @@
 	argv += optind;
 	argc -= optind;
 	
-	if (pidset && *argv || !pidset && !*argv)
+	if ((pidset && *argv) || (!pidset && !*argv))
 		usage();
 			
 	if (inherit)
 		trpoints |= KTRFAC_INHERIT;
 
-	(void)signal(SIGSYS, no_ktrace);
+	signal(SIGSYS, no_ktrace);
 	if (clear != NOTSET) {
 		if (clear == CLEARALL) {
 			ops = KTROP_CLEAR | KTRFLAG_DESCEND;
@@ -141,8 +144,8 @@
 		    DEFFILEMODE)) < 0)
 			err(1, "%s", tracefile);
 	}
-	(void)umask(omask);
-	(void)close(fd);
+	umask(omask);
+	close(fd);
 
 	if (*argv) { 
 		if (ktrace(tracefile, ops, trpoints, getpid()) < 0)
@@ -155,6 +158,7 @@
 	exit(0);
 }
 
+int
 rpid(char *p)
 {
 	static int first;
@@ -173,16 +177,16 @@
 void
 usage(void)
 {
-	(void)fprintf(stderr, "%s\n%s\n",
+	fprintf(stderr, "%s\n%s\n",
 "usage: ktrace [-aCcdi] [-f trfile] [-g pgrp | -p pid] [-t cnisuw]",
 "       ktrace [-adi] [-f trfile] [-t cnisuw] command");
 	exit(1);
 }
 
 void
-no_ktrace(int sig)
+no_ktrace(__unused int sig)
 {
-        (void)fprintf(stderr,
+        fprintf(stderr,
 "error:\tktrace() system call not supported in the running kernel\n\tre-compile kernel with 'options KTRACE'\n");
         exit(1);
 }
Index: ktrace.h
===================================================================
RCS file: /home/dcvs/src/usr.bin/ktrace/ktrace.h,v
retrieving revision 1.1
diff -u -r1.1 ktrace.h
--- ktrace.h	17 Jun 2003 02:56:13 -0000	1.1
+++ ktrace.h	9 Apr 2005 11:34:47 -0000
@@ -39,3 +39,5 @@
 #define ALL_POINTS (DEF_POINTS | KTRFAC_CSW)
 
 #define DEF_TRACEFILE	"ktrace.out"
+
+int getpoints(char *);
Index: subr.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/ktrace/subr.c,v
retrieving revision 1.5
diff -u -r1.5 subr.c
--- subr.c	21 Nov 2003 22:46:14 -0000	1.5
+++ subr.c	9 Apr 2005 12:04:46 -0000
@@ -35,8 +35,6 @@
  * $DragonFly: src/usr.bin/ktrace/subr.c,v 1.5 2003/11/21 22:46:14 dillon Exp $
  */
 
-#define _KERNEL_STRUCTURES
-
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/user.h>
@@ -47,12 +45,13 @@
 
 #include "ktrace.h"
 
+int
 getpoints(char *s)
 {
 	int facs = 0;
 
 	while (*s) {
-		switch(*s) {
+		switch (*s) {
 		case 'c':
 			facs |= KTRFAC_SYSCALL | KTRFAC_SYSRET;
 			break;
@@ -75,35 +74,9 @@
 			facs |= DEF_POINTS;
 			break;
 		default:
-			return (-1);
+			return(-1);
 		}
 		s++;
 	}
-	return (facs);
-}
-
-timevaladd(struct timeval *t1, struct timeval *t2)
-{
-	t1->tv_sec += t2->tv_sec;
-	t1->tv_usec += t2->tv_usec;
-	timevalfix(t1);
-}
-
-timevalsub(struct timeval *t1, struct timeval *t2)
-{
-	t1->tv_sec -= t2->tv_sec;
-	t1->tv_usec -= t2->tv_usec;
-	timevalfix(t1);
-}
-
-timevalfix(struct timeval *t1)
-{
-	if (t1->tv_usec < 0) {
-		t1->tv_sec--;
-		t1->tv_usec += 1000000;
-	}
-	if (t1->tv_usec >= 1000000) {
-		t1->tv_sec++;
-		t1->tv_usec -= 1000000;
-	}
+	return(facs);
 }


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]