Skip to contentSkip to conversation

mkfs.ubifs: eliminate compiler warnings

PATCH In review Adrian Hunter 2 participants 2 messages Feb 12, 2009 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.ubifs: eliminate compiler warnings

The warnings were:

lpt.c: In function ‘create_lpt’:
lpt.c:552: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long long int’ mkfs.ubifs.c: In function ‘do_openat’:
mkfs.ubifs.c:251: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result mkfs.ubifs.c: In function ‘get_options’:
mkfs.ubifs.c:542: warning: format not a string literal and no format arguments

---

mkfs.ubifs/lpt.c        |    2 +-
mkfs.ubifs/mkfs.ubifs.c |    5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
mkfs.ubifs/lpt.c +0 -0
index c8fb22c..f6d4352 100644
@@ -549,7 +549,7 @@ int create_lpt(struct ubifs_info *c)
	c->nhead_lnum = lnum;
	c->nhead_offs = ALIGN(len, c->min_io_size);

- dbg_msg(1, "lpt_sz: %d", c->lpt_sz);

+	dbg_msg(1, "lpt_sz:         %lld", c->lpt_sz);
	dbg_msg(1, "space_bits:     %d", c->space_bits);
	dbg_msg(1, "lpt_lnum_bits:  %d", c->lpt_lnum_bits);
	dbg_msg(1, "lpt_offs_bits:  %d", c->lpt_offs_bits);
mkfs.ubifs/mkfs.ubifs.c +0 -0
index 6c4e912..bedf8a7 100644
@@ -248,7 +248,8 @@ static int do_openat(int fd, const char *path, int flags)
	ret = fchdir(fd);
	if (ret != -1)
		ret = open(path, flags);
-	chdir(cwd);
+	if (chdir(cwd) && !ret)
+		ret = -1;
	free(cwd);
	return ret;
}
@@ -539,7 +540,7 @@ static int get_options(int argc, char**argv)
			break;
		case 'h':
		case '?':
-			printf(helptext);
+			printf("%s", helptext);
			exit(0);
		case 'v':
			verbose = 1;
Signature · 1 line
1.5.6.3
#1 lore raw

mkfs.ubifs/mkfs.ubifs.c static int do_openat(int fd, const char *path, int flags) · line 255

Quoted 12 lines · Adrian Hunter
mkfs.ubifs/mkfs.ubifs.c +2 -1
@@ -248,7 +248,8 @@ static int do_openat(int fd, const char *path, int flags)
       ret = fchdir(fd);
       if (ret != -1)
               ret = open(path, flags);
-       chdir(cwd);
+       if (chdir(cwd) && !ret)
+               ret = -1;
       free(cwd);
       return ret;
 }

does gcc do the right thing and re-order this ? or re-order it yourself so the intent stays clear ...

mkfs.ubifs/mkfs.ubifs.c

Quoted 5 lines
               case 'h':
               case '?':
mkfs.ubifs/mkfs.ubifs.c +1 -1
-                       printf(helptext);
+                       printf("%s", helptext);
                       exit(0);

puts() would be less overhead ... just make sure helptext doesnt have a trailing \n ...
-mike