diff --git a/tests/zfs-tests/cmd/draid.c b/tests/zfs-tests/cmd/draid.c index 76fdb4e841..46d7b4dcc6 100644 --- a/tests/zfs-tests/cmd/draid.c +++ b/tests/zfs-tests/cmd/draid.c @@ -93,8 +93,8 @@ read_map(const char *filename, nvlist_t **allcfgs) rc = gzread(fp, buf + bytes, block_size); if ((rc < 0) || (rc == 0 && !gzeof(fp))) { free(buf); - (void) gzclose(fp); (void) gzerror(fp, &error); + (void) gzclose(fp); return (error); } else { bytes += rc; @@ -505,6 +505,8 @@ eval_resilver(draid_map_t *map, uint64_t groupwidth, uint64_t nspares, int *ios = calloc(map->dm_children, sizeof (uint64_t)); + ASSERT3P(ios, !=, NULL); + /* Resilver all rows */ for (int i = 0; i < map->dm_nperms; i++) { uint8_t *row = &map->dm_perms[i * map->dm_children]; @@ -770,7 +772,7 @@ static int draid_generate(int argc, char *argv[]) { char filename[MAXPATHLEN] = {0}; - uint64_t map_seed; + uint64_t map_seed[2]; int c, fd, error, verbose = 0, passes = 1, continuous = 0; int min_children = VDEV_DRAID_MIN_CHILDREN; int max_children = VDEV_DRAID_MAX_CHILDREN; @@ -847,7 +849,7 @@ restart: ssize_t bytes_read = 0; while (bytes_read < bytes) { - ssize_t rc = read(fd, ((char *)&map_seed) + bytes_read, + ssize_t rc = read(fd, ((char *)map_seed) + bytes_read, bytes - bytes_read); if (rc < 0) { printf("Unable to read /dev/urandom: %s\n:", @@ -876,7 +878,7 @@ restart: double worst_ratio = 1000.0; double avg_ratio = 1000.0; - error = eval_maps(children, passes, &map_seed, &map, + error = eval_maps(children, passes, map_seed, &map, &worst_ratio, &avg_ratio); if (error) { printf("Error eval_maps(): %s\n", strerror(error)); diff --git a/tests/zfs-tests/cmd/file/file_trunc.c b/tests/zfs-tests/cmd/file/file_trunc.c index 2085f5955e..9e3bba24af 100644 --- a/tests/zfs-tests/cmd/file/file_trunc.c +++ b/tests/zfs-tests/cmd/file/file_trunc.c @@ -53,7 +53,7 @@ static long fsize = FSIZE; static size_t bsize = BSIZE; static int count = 0; static int rflag = 0; -static int seed = 0; +static uint_t seed = 0; static int vflag = 0; static int errflag = 0; static off_t offset = 0; @@ -105,7 +105,7 @@ parse_options(int argc, char *argv[]) extern int optind, optopt; count = fsize / bsize; - seed = time(NULL); + seed = (uint_t)time(NULL); while ((c = getopt(argc, argv, "b:c:f:o:rs:v")) != -1) { switch (c) { case 'b': diff --git a/tests/zfs-tests/cmd/file/randwritecomp.c b/tests/zfs-tests/cmd/file/randwritecomp.c index cc70d1212f..2d5c0ec864 100644 --- a/tests/zfs-tests/cmd/file/randwritecomp.c +++ b/tests/zfs-tests/cmd/file/randwritecomp.c @@ -152,6 +152,11 @@ main(int argc, char *argv[]) n = strtoull(argv[0], NULL, 0); fd = open(filename, O_RDWR|O_CREAT, 0666); + if (fd == -1) { + (void) fprintf(stderr, "open(%s) failed: %s\n", filename, + strerror(errno)); + exit(EXIT_FAILURE); + } err = fstat(fd, &ss); if (err != 0) { (void) fprintf(stderr, diff --git a/tests/zfs-tests/cmd/get_diff.c b/tests/zfs-tests/cmd/get_diff.c index 3f8fe787f7..61467f2501 100644 --- a/tests/zfs-tests/cmd/get_diff.c +++ b/tests/zfs-tests/cmd/get_diff.c @@ -96,7 +96,7 @@ main(int argc, char *argv[]) off += bytes; } - if (diff_len != 0 && diff_len != 0) { + if (diff_len != 0) { (void) fprintf(stdout, "%lld,%lld\n", (long long)diff_off, (long long)diff_len); } diff --git a/tests/zfs-tests/cmd/libzfs_input_check.c b/tests/zfs-tests/cmd/libzfs_input_check.c index 434cc863f3..2e1859b1ee 100644 --- a/tests/zfs-tests/cmd/libzfs_input_check.c +++ b/tests/zfs-tests/cmd/libzfs_input_check.c @@ -528,7 +528,11 @@ test_recv_new(const char *dataset, int fd) ssize_t count; int cleanup_fd = open(ZFS_DEV, O_RDWR); - + if (cleanup_fd == -1) { + (void) fprintf(stderr, "open(%s) failed: %s\n", ZFS_DEV, + strerror(errno)); + exit(EXIT_FAILURE); + } (void) snprintf(snapshot, sizeof (snapshot), "%s@replicant", dataset); count = pread(fd, &drr, sizeof (drr), 0); diff --git a/tests/zfs-tests/cmd/mmapwrite.c b/tests/zfs-tests/cmd/mmapwrite.c index 8534db3396..ca55d730fd 100644 --- a/tests/zfs-tests/cmd/mmapwrite.c +++ b/tests/zfs-tests/cmd/mmapwrite.c @@ -66,7 +66,7 @@ normal_writer(void *filename) err(1, "failed to open %s", file_path); } - char buf; + char buf = 'z'; while (1) { write_num = write(fd, &buf, 1); if (write_num == 0) { diff --git a/tests/zfs-tests/cmd/readmmap.c b/tests/zfs-tests/cmd/readmmap.c index c4812b4a25..704ffd55c8 100644 --- a/tests/zfs-tests/cmd/readmmap.c +++ b/tests/zfs-tests/cmd/readmmap.c @@ -55,7 +55,7 @@ main(int argc, char **argv) char *buf = NULL; char *map = NULL; int fd = -1, bytes, retval = 0; - unsigned seed; + uint_t seed; if (argc < 2 || optind == argc) { (void) fprintf(stderr, @@ -92,7 +92,7 @@ main(int argc, char **argv) retval = 1; goto end; } - seed = time(NULL); + seed = (uint_t)time(NULL); srandom(seed); idx = random() % size; diff --git a/tests/zfs-tests/cmd/zed_fd_spill-zedlet.c b/tests/zfs-tests/cmd/zed_fd_spill-zedlet.c index c072f906d2..b248579abb 100644 --- a/tests/zfs-tests/cmd/zed_fd_spill-zedlet.c +++ b/tests/zfs-tests/cmd/zed_fd_spill-zedlet.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -28,7 +29,19 @@ int main(void) { char buf[64]; sprintf(buf, "/tmp/zts-zed_fd_spill-logdir/%d", getppid()); - dup2(creat(buf, 0644), STDOUT_FILENO); + int fd = creat(buf, 0644); + if (fd == -1) { + (void) fprintf(stderr, "creat(%s) failed: %s\n", buf, + strerror(errno)); + exit(EXIT_FAILURE); + } + + if (dup2(fd, STDOUT_FILENO) == -1) { + close(fd); + (void) fprintf(stderr, "dup2(%s, STDOUT_FILENO) failed: %s\n", + buf, strerror(errno)); + exit(EXIT_FAILURE); + } snprintf(buf, sizeof (buf), "/proc/%d/fd", getppid()); execlp("ls", "ls", buf, NULL);