summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorSami Kerola2017-02-11 21:23:26 +0100
committerKarel Zak2017-02-20 12:58:49 +0100
commit87918040658f2fa9b1bf78f1f8f4f5c065a2e3a3 (patch)
tree513541cfa347d7fc66e50137603489cb195c86de /disk-utils
parentcfdisk: avoid use of VLA in combination with sizeof() [smatch scan] (diff)
downloadkernel-qcow2-util-linux-87918040658f2fa9b1bf78f1f8f4f5c065a2e3a3.tar.gz
kernel-qcow2-util-linux-87918040658f2fa9b1bf78f1f8f4f5c065a2e3a3.tar.xz
kernel-qcow2-util-linux-87918040658f2fa9b1bf78f1f8f4f5c065a2e3a3.zip
misc: do not use plain 0 as NULL [smatch scan]
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/addpart.c6
-rw-r--r--disk-utils/cfdisk.c2
-rw-r--r--disk-utils/delpart.c6
-rw-r--r--disk-utils/fsck.c24
-rw-r--r--disk-utils/fsck.cramfs.c18
-rw-r--r--disk-utils/isosize.c10
-rw-r--r--disk-utils/mkfs.cramfs.c6
-rw-r--r--disk-utils/mkswap.c18
-rw-r--r--disk-utils/raw.c10
-rw-r--r--disk-utils/resizepart.c6
-rw-r--r--disk-utils/sfdisk.c2
-rw-r--r--disk-utils/swaplabel.c10
12 files changed, 59 insertions, 59 deletions
diff --git a/disk-utils/addpart.c b/disk-utils/addpart.c
index e003b18b5..f99e9bc9c 100644
--- a/disk-utils/addpart.c
+++ b/disk-utils/addpart.c
@@ -29,9 +29,9 @@ int main(int argc, char **argv)
int c, fd;
static const struct option longopts[] = {
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'V'},
- {NULL, no_argument, 0, '0'},
+ {"help", no_argument, NULL, 'h'},
+ {"version", no_argument, NULL, 'V'},
+ {NULL, 0, NULL, 0},
};
setlocale(LC_ALL, "");
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c
index 19b62f24b..4ad52842c 100644
--- a/disk-utils/cfdisk.c
+++ b/disk-utils/cfdisk.c
@@ -2573,7 +2573,7 @@ int main(int argc, char *argv[])
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "zero", no_argument, NULL, 'z' },
- { NULL, 0, 0, 0 },
+ { NULL, 0, NULL, 0 },
};
setlocale(LC_ALL, "");
diff --git a/disk-utils/delpart.c b/disk-utils/delpart.c
index d39401f6f..1f82b58e9 100644
--- a/disk-utils/delpart.c
+++ b/disk-utils/delpart.c
@@ -29,9 +29,9 @@ int main(int argc, char **argv)
int c, fd;
static const struct option longopts[] = {
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'V'},
- {NULL, no_argument, 0, '0'},
+ {"help", no_argument, NULL, 'h'},
+ {"version", no_argument, NULL, 'V'},
+ {NULL, 0, NULL, 0},
};
setlocale(LC_ALL, "");
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index 68b768ea1..93296c97d 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -652,7 +652,7 @@ static int execute(const char *progname, const char *progpath,
}
argv[argc++] = xstrdup(fs_get_device(fs));
- argv[argc] = 0;
+ argv[argc] = NULL;
if (verbose || noexecute) {
const char *tgt = mnt_fs_get_target(fs);
@@ -742,7 +742,7 @@ static struct fsck_instance *wait_one(int flags)
if (noexecute) {
inst = instance_list;
- prev = 0;
+ prev = NULL;
#ifdef RANDOM_DEBUG
while (inst->next && (random() & 1)) {
prev = inst;
@@ -777,7 +777,7 @@ static struct fsck_instance *wait_one(int flags)
warn(_("waitpid failed"));
continue;
}
- for (prev = 0, inst = instance_list;
+ for (prev = NULL, inst = instance_list;
inst;
prev = inst, inst = inst->next) {
if (inst->pid == pid)
@@ -823,7 +823,7 @@ static struct fsck_instance *wait_one(int flags)
* bit before sending the kill, to give it
* time to set up the signal handler
*/
- if (inst2->start_time.tv_sec < time(0) + 2) {
+ if (inst2->start_time.tv_sec < time(NULL) + 2) {
if (fork() == 0) {
sleep(1);
kill(inst2->pid, SIGUSR1);
@@ -1029,7 +1029,7 @@ static int fs_match(struct libmnt_fs *fs, struct fs_type_compile *cmp)
int n, ret = 0, checked_type = 0;
char *cp;
- if (cmp->list == 0 || cmp->list[0] == 0)
+ if (cmp->list == NULL || cmp->list[0] == NULL)
return 1;
for (n=0; (cp = cmp->list[n]); n++) {
@@ -1175,7 +1175,7 @@ static int count_slaves(dev_t disk)
if (!(dir = opendir(dirname)))
return -1;
- while ((dp = readdir(dir)) != 0) {
+ while ((dp = readdir(dir)) != NULL) {
#ifdef _DIRENT_HAVE_D_TYPE
if (dp->d_type != DT_UNKNOWN && dp->d_type != DT_LNK)
continue;
@@ -1217,7 +1217,7 @@ static int disk_already_active(struct libmnt_fs *fs)
* Don't check a stacked device with any other disk too.
*/
if (!disk || fs_is_stacked(fs))
- return (instance_list != 0);
+ return (instance_list != NULL);
for (inst = instance_list; inst; inst = inst->next) {
dev_t idisk = fs_get_disk(inst->fs, 0);
@@ -1410,7 +1410,7 @@ static void signal_cancel(int sig __attribute__((__unused__)))
static void parse_argv(int argc, char *argv[])
{
int i, j;
- char *arg, *dev, *tmp = 0;
+ char *arg, *dev, *tmp = NULL;
char options[128];
int opt = 0;
int opts_for_fsck = 0;
@@ -1422,12 +1422,12 @@ static void parse_argv(int argc, char *argv[])
*/
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_handler = signal_cancel;
- sigaction(SIGINT, &sa, 0);
- sigaction(SIGTERM, &sa, 0);
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
num_devices = 0;
num_args = 0;
- instance_list = 0;
+ instance_list = NULL;
for (i=1; i < argc; i++) {
arg = argv[i];
@@ -1534,7 +1534,7 @@ static void parse_argv(int argc, char *argv[])
serialize = 1;
break;
case 't':
- tmp = 0;
+ tmp = NULL;
if (fstype)
usage(stderr);
if (arg[j+1])
diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index 9e7bab898..81e17be27 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -220,7 +220,7 @@ static void test_crc(int start)
return;
}
- crc = crc32(0L, Z_NULL, 0);
+ crc = crc32(0L, NULL, 0);
buf =
mmap(NULL, super.size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
@@ -237,7 +237,7 @@ static void test_crc(int start)
}
if (buf != MAP_FAILED) {
((struct cramfs_super *)((unsigned char *) buf + start))->fsid.crc =
- crc32(0L, Z_NULL, 0);
+ crc32(0L, NULL, 0);
crc = crc32(crc, (unsigned char *) buf + start, super.size - start);
munmap(buf, super.size);
} else {
@@ -255,7 +255,7 @@ static void test_crc(int start)
break;
if (length == 0)
((struct cramfs_super *)buf)->fsid.crc =
- crc32(0L, Z_NULL, 0);
+ crc32(0L, NULL, 0);
length += retval;
if (length > (super.size - start)) {
crc = crc32(crc, buf,
@@ -646,12 +646,12 @@ int main(int argc, char **argv)
size_t length = 0;
static const struct option longopts[] = {
- {"verbose", no_argument, 0, 'v'},
- {"version", no_argument, 0, 'V'},
- {"help", no_argument, 0, 'h'},
- {"blocksize", required_argument, 0, 'b'},
- {"extract", optional_argument, 0, 'x'},
- {NULL, no_argument, 0, '0'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"version", no_argument, NULL, 'V'},
+ {"help", no_argument, NULL, 'h'},
+ {"blocksize", required_argument, NULL, 'b'},
+ {"extract", optional_argument, NULL, 'x'},
+ {NULL, 0, NULL, 0},
};
setlocale(LC_MESSAGES, "");
diff --git a/disk-utils/isosize.c b/disk-utils/isosize.c
index cd8a16fc8..d3d11c921 100644
--- a/disk-utils/isosize.c
+++ b/disk-utils/isosize.c
@@ -190,11 +190,11 @@ int main(int argc, char **argv)
long divisor = 0;
static const struct option longopts[] = {
- {"divisor", required_argument, 0, 'd'},
- {"sectors", no_argument, 0, 'x'},
- {"version", no_argument, 0, 'V'},
- {"help", no_argument, 0, 'h'},
- {NULL, 0, 0, 0}
+ {"divisor", required_argument, NULL, 'd'},
+ {"sectors", no_argument, NULL, 'x'},
+ {"version", no_argument, NULL, 'V'},
+ {"help", no_argument, NULL, 'h'},
+ {NULL, 0, NULL, 0}
};
setlocale(LC_ALL, "");
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 3c7d0f599..f277aaf23 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -302,7 +302,7 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
endpath++;
/* read in the directory and sort */
- dircount = scandir(name, &dirlist, 0, cramsort);
+ dircount = scandir(name, &dirlist, NULL, cramsort);
if (dircount < 0)
err(MKFS_EX_ERROR, _("could not read directory %s"), name);
@@ -412,7 +412,7 @@ static unsigned int write_superblock(struct entry *root, char *base, int size)
super->size = size;
memcpy(super->signature, CRAMFS_SIGNATURE, sizeof(super->signature));
- super->fsid.crc = crc32(0L, Z_NULL, 0);
+ super->fsid.crc = crc32(0L, NULL, 0);
super->fsid.edition = opt_edition;
super->fsid.blocks = total_blocks;
super->fsid.files = total_nodes;
@@ -706,7 +706,7 @@ int main(int argc, char **argv)
loff_t fslen_ub = sizeof(struct cramfs_super);
unsigned int fslen_max;
char const *dirname, *outfile;
- uint32_t crc = crc32(0L, Z_NULL, 0);
+ uint32_t crc = crc32(0L, NULL, 0);
int c;
cramfs_is_big_endian = HOST_IS_BIG_ENDIAN; /* default is to use host order */
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index b367117dd..ea93f9b3a 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -352,15 +352,15 @@ int main(int argc, char **argv)
uuid_t uuid_dat;
#endif
static const struct option longopts[] = {
- { "check", no_argument, 0, 'c' },
- { "force", no_argument, 0, 'f' },
- { "pagesize", required_argument, 0, 'p' },
- { "label", required_argument, 0, 'L' },
- { "swapversion", required_argument, 0, 'v' },
- { "uuid", required_argument, 0, 'U' },
- { "version", no_argument, 0, 'V' },
- { "help", no_argument, 0, 'h' },
- { NULL, 0, 0, 0 }
+ { "check", no_argument, NULL, 'c' },
+ { "force", no_argument, NULL, 'f' },
+ { "pagesize", required_argument, NULL, 'p' },
+ { "label", required_argument, NULL, 'L' },
+ { "swapversion", required_argument, NULL, 'v' },
+ { "uuid", required_argument, NULL, 'U' },
+ { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
+ { NULL, 0, NULL, 0 }
};
setlocale(LC_ALL, "");
diff --git a/disk-utils/raw.c b/disk-utils/raw.c
index 77945bc0f..d5c2a681f 100644
--- a/disk-utils/raw.c
+++ b/disk-utils/raw.c
@@ -100,11 +100,11 @@ int main(int argc, char *argv[])
struct stat statbuf;
static const struct option longopts[] = {
- {"query", no_argument, 0, 'q'},
- {"all", no_argument, 0, 'a'},
- {"version", no_argument, 0, 'V'},
- {"help", no_argument, 0, 'h'},
- {NULL, no_argument, 0, '0'},
+ {"query", no_argument, NULL, 'q'},
+ {"all", no_argument, NULL, 'a'},
+ {"version", no_argument, NULL, 'V'},
+ {"help", no_argument, NULL, 'h'},
+ {NULL, 0, NULL, '0'},
};
setlocale(LC_ALL, "");
diff --git a/disk-utils/resizepart.c b/disk-utils/resizepart.c
index 5c6c0497a..97533e26f 100644
--- a/disk-utils/resizepart.c
+++ b/disk-utils/resizepart.c
@@ -70,9 +70,9 @@ int main(int argc, char **argv)
uint64_t start;
static const struct option longopts[] = {
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'V'},
- {NULL, no_argument, 0, '0'},
+ {"help", no_argument, NULL, 'h'},
+ {"version", no_argument, NULL, 'V'},
+ {NULL, 0, NULL, '0'},
};
setlocale(LC_ALL, "");
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index cf6d96df5..b304acb53 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -1980,7 +1980,7 @@ int main(int argc, char *argv[])
{ "id", no_argument, NULL, 'c' }, /* deprecated */
{ "print-id",no_argument, NULL, OPT_PRINT_ID }, /* deprecated */
- { NULL, 0, 0, 0 },
+ { NULL, 0, NULL, 0 },
};
setlocale(LC_ALL, "");
diff --git a/disk-utils/swaplabel.c b/disk-utils/swaplabel.c
index 046efb495..233f027d1 100644
--- a/disk-utils/swaplabel.c
+++ b/disk-utils/swaplabel.c
@@ -137,11 +137,11 @@ int main(int argc, char *argv[])
int c, rc = -1;
static const struct option longopts[] = {
- { "help", 0, 0, 'h' },
- { "version", 0, 0, 'V' },
- { "label", 1, 0, 'L' },
- { "uuid", 1, 0, 'U' },
- { NULL, 0, 0, 0 }
+ { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'V' },
+ { "label", required_argument, NULL, 'L' },
+ { "uuid", required_argument, NULL, 'U' },
+ { NULL, 0, NULL, 0 }
};
setlocale(LC_ALL, "");