Skip to contentSkip to conversation

xfsprogs: fix some trivial sparse warnings

PATCH New Christoph Hellwig 1 participant 1 message Aug 11, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsprogs: fix some trivial sparse warnings

Fix some trivial not endianess related sparse warnings in xfsprogs:

- change the ASSERT defintion to avoid too deep token expansion warnings
- fix 0 vs NULL noise
- make sure functions without paramter are declared with a void pseudo-paramter so that they are proper ANSI declarations and can't be confused with a K&R declaration.

include/platform_defs.h.in +1 -1
Index: xfsprogs/include/platform_defs.h.in
===================================================================
@@ -130,7 +132,7 @@ typedef unsigned long long __psunsigned_
 #include <locale.h>
 
 #ifdef DEBUG
-# define ASSERT		assert
+# define ASSERT(EX)		assert(EX)
 #else
 # define ASSERT(EX)	((void) 0)
 #endif
io/parent.c +1 -1
Index: xfsprogs/io/parent.c
===================================================================
@@ -242,7 +242,7 @@ parent_check(void)
         fsfd = file->fd;
 
 	fshandlep = jdm_getfshandle(mntpt);
-	if (fshandlep == 0) {
+	if (fshandlep == NULL) {
 		fprintf(stderr, _("unable to open \"%s\" for jdm: %s\n"),
 		      mntpt,
 		      strerror(errno));
libdisk/fstype.c +3 -3
Index: xfsprogs/libdisk/fstype.c
===================================================================
@@ -199,11 +199,11 @@ fstype(const char *device) {
        to a block device or ordinary file */
     if (stat (device, &statbuf) ||
 	!(S_ISBLK(statbuf.st_mode) || S_ISREG(statbuf.st_mode)))
-      return 0;
+      return NULL;
 
     fd = open(device, O_RDONLY);
     if (fd < 0)
-      return 0;
+      return NULL;
 
     /* do seeks and reads in disk order, otherwise a very short
        partition may cause a failure because of read error */
@@ -409,5 +409,5 @@ fstype(const char *device) {
 
 io_error:
     close(fd);
-    return 0;
+    return NULL;
 }
libhandle/jdm.c +1 -1
Index: xfsprogs/libhandle/jdm.c
===================================================================
@@ -70,7 +70,7 @@ jdm_getfshandle( char *mntpnt )
 	ASSERT( sizeofmember( filehandle_t, fh_pad ) == FILEHANDLE_SZ_PAD );
 	ASSERT( FILEHANDLE_SZ_PAD == sizeof( int16_t ));
 
-	fshandlep = 0; /* for lint */
+	fshandlep = NULL; /* for lint */
 	fshandlesz = sizeof( *fshandlep );
 
 	if (!realpath( mntpnt, resolved ))
libxcmd/projects.c +2 -2
Index: xfsprogs/libxcmd/projects.c
===================================================================
@@ -44,14 +44,14 @@ setprfiles(void)
 }
 
 void
-setprent()
+setprent(void)
 {
 	setprfiles();
 	projects = fopen(projid_file, "r");
 }
 
 void
-setprpathent()
+setprpathent(void)
 {
 	setprfiles();
 	project_paths = fopen(projects_file, "r");
mdrestore/xfs_mdrestore.c +1 -1
Index: xfsprogs/mdrestore/xfs_mdrestore.c
===================================================================
@@ -121,7 +121,7 @@ perform_restore(
 	} else  {
 		/* ensure device is sufficiently large enough */
 
-		char		*lb[XFS_MAX_SECTORSIZE] = { 0 };
+		char		*lb[XFS_MAX_SECTORSIZE] = { NULL };
 		off64_t		off;
 
 		off = sb.sb_dblocks * sb.sb_blocksize - sizeof(lb);
mkfs/proto.c +2 -2
Index: xfsprogs/mkfs/proto.c
===================================================================
@@ -255,7 +255,7 @@ newfile(
 			exit(1);
 		}
 		d = XFS_FSB_TO_DADDR(mp, map.br_startblock);
-		bp = libxfs_trans_get_buf(logit ? tp : 0, mp->m_dev, d,
+		bp = libxfs_trans_get_buf(logit ? tp : NULL, mp->m_dev, d,
 			nb << mp->m_blkbb_log, 0);
 		memmove(XFS_BUF_PTR(bp), buf, len);
 		if (len < XFS_BUF_COUNT(bp))
@@ -293,7 +293,7 @@ newregfile(
 			exit(1);
 		}
 	} else
-		buf = 0;
+		buf = NULL;
 	close(fd);
 	return buf;
 }
quota/quot.c +3 -3
Index: xfsprogs/quota/quot.c
===================================================================
@@ -107,7 +107,7 @@ quot_bulkstat_add(
 		for (dp = *hp; dp; dp = dp->next)
 			if (dp->id == id)
 				break;
-		if (dp == 0) {
+		if (dp == NULL) {
 			if (ndu[i] >= NDU)
 				return;
 			dp = &du[i][(ndu[i]++)];
@@ -153,7 +153,7 @@ quot_bulkstat_mount(
 	overflow = 0;
 	for (i = 0; i < 3; i++)
 		for (dp = duhash[i]; dp < &duhash[i][DUHASH]; dp++)
-			*dp = 0;
+			*dp = NULL;
 	ndu[0] = ndu[1] = ndu[2] = 0;
 
 	fsfd = open(fsdir, O_RDONLY);
@@ -275,7 +275,7 @@ quot_report(
 	fs_cursor_t	cursor;
 	fs_path_t	*mount;
 
-	now = time(0);
+	now = time(NULL);
 	fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
 	while ((mount = fs_cursor_next_entry(&cursor))) {
 		quot_bulkstat_mount(mount->fs_dir, flags);
repair/xfs_repair.c +6 -6
Index: xfsprogs/repair/xfs_repair.c
===================================================================
@@ -245,18 +245,18 @@ process_args(int argc, char **argv)
 					pre_65_beta = 1;
 					break;
 				case IHASH_SIZE:
-					libxfs_ihash_size = (int) strtol(val, 0, 0);
+					libxfs_ihash_size = (int) strtol(val, NULL, 0);
 					ihash_option_used = 1;
 					break;
 				case BHASH_SIZE:
 					if (max_mem_specified)
 						do_abort(
 			_("-o bhash option cannot be used with -m option\n"));
-					libxfs_bhash_size = (int) strtol(val, 0, 0);
+					libxfs_bhash_size = (int) strtol(val, NULL, 0);
 					bhash_option_used = 1;
 					break;
 				case AG_STRIDE:
-					ag_stride = (int) strtol(val, 0, 0);
+					ag_stride = (int) strtol(val, NULL, 0);
 					break;
 				default:
 					unknown('o', val);
@@ -271,7 +271,7 @@ process_args(int argc, char **argv)
 
 				switch (getsubopt(&p, (constpp)c_opts, &val)) {
 				case CONVERT_LAZY_COUNT:
-					lazy_count = (int)strtol(val, 0, 0);
+					lazy_count = (int)strtol(val, NULL, 0);
 					convert_lazy_count = 1;
 					break;
 				default:
@@ -295,7 +295,7 @@ process_args(int argc, char **argv)
 			if (bhash_option_used)
 				do_abort(_("-m option cannot be used with "
 						"-o bhash option\n"));
-			max_mem_specified = strtol(optarg, 0, 0);
+			max_mem_specified = strtol(optarg, NULL, 0);
 			break;
 		case 'L':
 			zap_log = 1;
@@ -316,7 +316,7 @@ process_args(int argc, char **argv)
 			do_prefetch = 0;
 			break;
 		case 't':
-			report_interval = (int) strtol(optarg, 0, 0);
+			report_interval = (int) strtol(optarg, NULL, 0);
 			break;
 		case '?':
 			usage();
rtcp/xfs_rtcp.c +1 -1
Index: xfsprogs/rtcp/xfs_rtcp.c
===================================================================
@@ -25,7 +25,7 @@ int pflag;
 char *progname;
 
 void
-usage()
+usage(void)
 {
 	fprintf(stderr, _("%s [-e extsize] [-p] source target\n"), progname);
 	exit(2);
mkfs/xfs_mkfs.c +1 -1
Index: xfsprogs/mkfs/xfs_mkfs.c
===================================================================
@@ -1258,7 +1258,7 @@ main(
 			break;
 		case 'p':
 			if (protofile)
-				respec('p', 0, 0);
+				respec('p', NULL, 0);
 			protofile = optarg;
 			break;
 		case 'q':