]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
various: fix variable and function declarations [smatch scan]
authorSami Kerola <kerolasa@iki.fi>
Mon, 8 Apr 2013 19:32:49 +0000 (20:32 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 9 Apr 2013 10:17:20 +0000 (12:17 +0200)
disk-utils/fsck.minix.c:511:9: warning: mixing declarations and code
fdisks/sfdisk.c:982:5: warning: mixing declarations and code
fdisks/sfdisk.c:1254:5: warning: mixing declarations and code
fdisks/sfdisk.c:1564:5: warning: mixing declarations and code
lib/mbsalign.c:279:7: warning: mixing declarations and code
libblkid/src/devname.c:378:17: warning: mixing declarations and code
libfdisk/src/alignment.c:219:9: warning: mixing declarations and code
term-utils/wall.c:111:9: warning: mixing declarations and code
text-utils/col.c:418:19: warning: non-ANSI function declaration of function 'flush_blanks'
text-utils/col.c:553:12: warning: non-ANSI function declaration of function 'alloc_line'
text-utils/rev.c:105:9: warning: mixing declarations and code
text-utils/tailf.c:245:9: warning: mixing declarations and code

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
disk-utils/fsck.minix.c
fdisks/sfdisk.c
lib/mbsalign.c
libblkid/src/devname.c
libfdisk/src/alignment.c
term-utils/wall.c
text-utils/col.c
text-utils/rev.c
text-utils/tailf.c

index 3482200c24ea77ce1db9c039da9a6860c2a157b4..89e96fcfbf562e2747a96d356fdf60aff5cc9b36 100644 (file)
@@ -507,11 +507,12 @@ write_super_block(void) {
 
 static void
 write_tables(void) {
-       write_super_block();
        unsigned long buffsz = get_inode_buffer_size();
        unsigned long imaps = get_nimaps();
        unsigned long zmaps = get_nzmaps();
 
+       write_super_block();
+
        if (write_all(IN, inode_map, imaps * MINIX_BLOCK_SIZE))
                die(_("Unable to write inode map"));
 
index d98df9a96aaad76de7d7aeb8284502c4f1510460..3206a6bac3e458875327fbd5d445e257981e8d75 100644 (file)
@@ -977,10 +977,10 @@ out_roundup_size(int width, unsigned long long n, unsigned long unit) {
 static struct geometry
 get_fdisk_geometry_one(struct part_desc *p) {
     struct geometry G;
-
-    memset(&G, 0, sizeof(struct geometry));
     chs b = p->p.end_chs;
     longchs bb = chs_to_longchs(b);
+
+    memset(&G, 0, sizeof(struct geometry));
     G.heads = bb.h + 1;
     G.sectors = bb.s;
     G.cylindersize = G.heads * G.sectors;
@@ -1167,6 +1167,7 @@ static int
 partitions_ok(int fd, struct disk_desc *z) {
     struct part_desc *partitions = &(z->partitions[0]), *p, *q;
     int partno = z->partno;
+    int sector_size;
 
 #define PNO(p) pnumber(p, z)
 
@@ -1251,7 +1252,6 @@ partitions_ok(int fd, struct disk_desc *z) {
            }
     }
 
-    int sector_size;
     if (blkdev_get_sector_size(fd, &sector_size) == -1)
        sector_size = DEFAULT_SECTOR_SIZE;
 
@@ -1538,6 +1538,7 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
     struct part_desc *partitions = &(z->partitions[0]);
     int pno = z->partno;
     int bsd_later = 1;
+    unsigned short sig, magic;
 #ifdef __linux__
     bsd_later = (get_linux_version() >= KERNEL_VERSION(2, 3, 40));
 #endif
@@ -1561,7 +1562,6 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
        return 0;
     }
 
-    unsigned short sig, magic;
     memcpy(&sig, s->data + 2, sizeof(sig));
     if (sig <= 0x1ae) {
        memcpy(&magic, s->data + sig, sizeof(magic));
index 05c46509a35a440463a9720495eaea017db17806..e420fea660237b237cafb444e7e31935a7d52093 100644 (file)
@@ -173,7 +173,7 @@ mbsalign (const char *src, char *dest, size_t dest_size,
   const char *str_to_print = src;
   size_t n_cols = src_size - 1;
   size_t n_used_bytes = n_cols; /* Not including NUL */
-  size_t n_spaces = 0;
+  size_t n_spaces = 0, space_left;
   bool conversion = false;
   bool wc_enabled = false;
 
@@ -276,7 +276,7 @@ mbsalign_unibyte:
         }
 
       dest = mbs_align_pad (dest, dest_end, start_spaces);
-      size_t space_left = dest_end - dest;
+      space_left = dest_end - dest;
       dest = mempcpy (dest, str_to_print, min (n_used_bytes, space_left));
       mbs_align_pad (dest, dest_end, end_spaces);
     }
index 1c1ab07f89efc0149dd37123a08e8627e3fd5f56..497deaf14829338458e1ed5d2d66d51149c910e3 100644 (file)
@@ -371,12 +371,12 @@ ubi_probe_all(blkid_cache cache, int only_if_new)
        const char **dirname;
 
        for (dirname = dirlist; *dirname; dirname++) {
-               DBG(DEVNAME, blkid_debug("probing UBI volumes under %s",
-                                         *dirname));
-
                DIR             *dir;
                struct dirent   *iter;
 
+               DBG(DEVNAME, blkid_debug("probing UBI volumes under %s",
+                                         *dirname));
+
                dir = opendir(*dirname);
                if (dir == NULL)
                        continue ;
index 25323d1b54e252c2dc77b1d39b6ee4416007a179..ac44e73c11ddcaec399ff8e3fd31b3be26c89363 100644 (file)
@@ -212,12 +212,13 @@ int fdisk_discover_geometry(struct fdisk_context *cxt)
 
 int fdisk_discover_topology(struct fdisk_context *cxt)
 {
+#ifdef HAVE_LIBBLKID
+       blkid_probe pr;
+#endif
        assert(cxt);
        assert(cxt->sector_size == 0);
 
 #ifdef HAVE_LIBBLKID
-       blkid_probe pr;
-
        DBG(TOPOLOGY, dbgprint("initialize libblkid prober"));
 
        pr = blkid_new_probe();
index c2ac7ad1263ededf70f89b1df505a7e639c823c6..4865ac7a137abb9f4f372c680542dc9f7bc1d8e9 100644 (file)
@@ -103,11 +103,6 @@ main(int argc, char **argv) {
        size_t mbufsize;
        unsigned timeout = WRITE_TIME_OUT;
 
-       setlocale(LC_ALL, "");
-       bindtextdomain(PACKAGE, LOCALEDIR);
-       textdomain(PACKAGE);
-       atexit(close_stdout);
-
        static const struct option longopts[] = {
                { "nobanner",   no_argument,            0, 'n' },
                { "timeout",    required_argument,      0, 't' },
@@ -116,6 +111,11 @@ main(int argc, char **argv) {
                { NULL, 0, 0, 0 }
        };
 
+       setlocale(LC_ALL, "");
+       bindtextdomain(PACKAGE, LOCALEDIR);
+       textdomain(PACKAGE);
+       atexit(close_stdout);
+
        while ((ch = getopt_long(argc, argv, "nt:Vh", longopts, NULL)) != -1) {
                switch (ch) {
                case 'n':
index c2b10dc515ad09d2723a56c852d7d48905a8fbd9..474b33fca3077d2f463a87e27218d554bf5700fc 100644 (file)
@@ -415,7 +415,7 @@ void flush_lines(int nflush)
  * is the number of half line feeds, otherwise it is the number of whole line
  * feeds.
  */
-void flush_blanks()
+void flush_blanks(void)
 {
        int half, i, nb;
 
@@ -550,7 +550,7 @@ void flush_line(LINE *l)
 static LINE *line_freelist;
 
 LINE *
-alloc_line()
+alloc_line(void)
 {
        LINE *l;
        int i;
index 00d519695594a8f6703a3190b26fee8d8b7fa6c1..95545064a616a97b24ac87771a0e1d6129fee4ff 100644 (file)
@@ -94,6 +94,12 @@ int main(int argc, char *argv[])
        FILE *fp = stdin;
        int ch, rval = EXIT_SUCCESS;
 
+       static const struct option longopts[] = {
+               { "version",    no_argument,       0, 'V' },
+               { "help",       no_argument,       0, 'h' },
+               { NULL,         0, 0, 0 }
+       };
+
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
@@ -102,12 +108,6 @@ int main(int argc, char *argv[])
        signal(SIGINT, sig_handler);
        signal(SIGTERM, sig_handler);
 
-       static const struct option longopts[] = {
-               { "version",    no_argument,       0, 'V' },
-               { "help",       no_argument,       0, 'h' },
-               { NULL,         0, 0, 0 }
-       };
-
        while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
                switch(ch) {
                case 'V':
index a8630fb6cba460d368fe8970ceeaaedf823878cb..2f611a4cb875da0338f13ca3e982e80636046528 100644 (file)
@@ -237,11 +237,6 @@ int main(int argc, char **argv)
        struct stat st;
        off_t size = 0;
 
-       setlocale(LC_ALL, "");
-       bindtextdomain(PACKAGE, LOCALEDIR);
-       textdomain(PACKAGE);
-       atexit(close_stdout);
-
        static const struct option longopts[] = {
                { "lines",   required_argument, 0, 'n' },
                { "version", no_argument,       0, 'V' },
@@ -249,6 +244,11 @@ int main(int argc, char **argv)
                { NULL,      0, 0, 0 }
        };
 
+       setlocale(LC_ALL, "");
+       bindtextdomain(PACKAGE, LOCALEDIR);
+       textdomain(PACKAGE);
+       atexit(close_stdout);
+
        lines = old_style_option(&argc, argv);
        if (lines < 0)
                lines = DEFAULT_LINES;