cstyle: Resolve C style issues

The vast majority of these changes are in Linux specific code.
They are the result of not having an automated style checker to
validate the code when it was originally written.  Others were
caused when the common code was slightly adjusted for Linux.

This patch contains no functional changes.  It only refreshes
the code to conform to style guide.

Everyone submitting patches for inclusion upstream should now
run 'make checkstyle' and resolve any warning prior to opening
a pull request.  The automated builders have been updated to
fail a build if when 'make checkstyle' detects an issue.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1821
This commit is contained in:
Michael Kjorling
2013-11-01 20:26:11 +01:00
committed by Brian Behlendorf
parent 8ffef572ed
commit d1d7e2689d
165 changed files with 2120 additions and 1936 deletions
-3
View File
@@ -461,9 +461,6 @@ libzfs_fru_clear(libzfs_handle_t *hdl, boolean_t final)
void
libzfs_fru_clear(libzfs_handle_t *hdl, boolean_t final)
{
return;
}
#endif /* HAVE_LIBTOPO */
+11 -11
View File
@@ -168,7 +168,7 @@ fix_paths(nvlist_t *nv, name_entry_t *names)
}
if ((strlen(path) == strlen(ne->ne_name)) &&
!strncmp(path, ne->ne_name, strlen(path))) {
strncmp(path, ne->ne_name, strlen(path)) == 0) {
best = ne;
break;
}
@@ -997,7 +997,7 @@ err_blkid3:
err_blkid2:
blkid_put_cache(cache);
err_blkid1:
return err;
return (err);
}
#endif /* HAVE_LIBBLKID */
@@ -1125,14 +1125,14 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
* when access from Xen dom0.
*/
if ((strncmp(name, "watchdog", 8) == 0) ||
(strncmp(name, "fuse", 4) == 0) ||
(strncmp(name, "ppp", 3) == 0) ||
(strncmp(name, "tty", 3) == 0) ||
(strncmp(name, "vcs", 3) == 0) ||
(strncmp(name, "parport", 7) == 0) ||
(strncmp(name, "lp", 2) == 0) ||
(strncmp(name, "fd", 2) == 0) ||
(strncmp(name, "hpet", 4) == 0) ||
(strncmp(name, "fuse", 4) == 0) ||
(strncmp(name, "ppp", 3) == 0) ||
(strncmp(name, "tty", 3) == 0) ||
(strncmp(name, "vcs", 3) == 0) ||
(strncmp(name, "parport", 7) == 0) ||
(strncmp(name, "lp", 2) == 0) ||
(strncmp(name, "fd", 2) == 0) ||
(strncmp(name, "hpet", 4) == 0) ||
(strncmp(name, "core", 4) == 0))
continue;
@@ -1165,7 +1165,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
ZPOOL_CONFIG_POOL_NAME, &pname) == 0)) {
if (strcmp(iarg->poolname, pname))
matched = B_FALSE;
matched = B_FALSE;
} else if (iarg->guid != 0) {
uint64_t this_guid;
+10 -10
View File
@@ -279,7 +279,7 @@ do_mount(const char *src, const char *mntpt, char *opts)
"-t", MNTTYPE_ZFS,
"-o", opts,
(char *)src,
(char *)mntpt,
(char *)mntpt,
(char *)NULL };
int rc;
@@ -287,22 +287,22 @@ do_mount(const char *src, const char *mntpt, char *opts)
rc = libzfs_run_process(argv[0], argv, STDOUT_VERBOSE|STDERR_VERBOSE);
if (rc) {
if (rc & MOUNT_FILEIO)
return EIO;
return (EIO);
if (rc & MOUNT_USER)
return EINTR;
return (EINTR);
if (rc & MOUNT_SOFTWARE)
return EPIPE;
return (EPIPE);
if (rc & MOUNT_BUSY)
return EBUSY;
return (EBUSY);
if (rc & MOUNT_SYSERR)
return EAGAIN;
return (EAGAIN);
if (rc & MOUNT_USAGE)
return EINVAL;
return (EINVAL);
return ENXIO; /* Generic error */
return (ENXIO); /* Generic error */
}
return 0;
return (0);
}
static int
@@ -890,7 +890,7 @@ zfs_unshare_proto(zfs_handle_t *zhp, const char *mountpoint,
mntpt = zfs_strdup(zhp->zfs_hdl, entry.mnt_mountp);
for (curr_proto = proto; *curr_proto != PROTO_END;
curr_proto++) {
curr_proto++) {
if (is_shared(hdl, mntpt, *curr_proto) &&
unshare_one(hdl, zhp->zfs_name,
+20 -17
View File
@@ -242,7 +242,7 @@ int
zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
zprop_source_t *srctype)
{
return zpool_get_prop_literal(zhp, prop, buf, len, srctype, B_FALSE);
return (zpool_get_prop_literal(zhp, prop, buf, len, srctype, B_FALSE));
}
/*
@@ -250,8 +250,8 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
* a pre-allocated buffer.
*/
int
zpool_get_prop_literal(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
zprop_source_t *srctype, boolean_t literal)
zpool_get_prop_literal(zpool_handle_t *zhp, zpool_prop_t prop, char *buf,
size_t len, zprop_source_t *srctype, boolean_t literal)
{
uint64_t intval;
const char *strval;
@@ -1222,8 +1222,9 @@ zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot,
* part of an active md or lvm device.
*/
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"one or more vdevs refer to the same device, or one of\n"
"the devices is part of an active md or lvm device"));
"one or more vdevs refer to the same device, or "
"one of\nthe devices is part of an active md or "
"lvm device"));
return (zfs_error(hdl, EZFS_BADDEV, msg));
case EOVERFLOW:
@@ -2427,7 +2428,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,
if (path[0] != '/') {
error = zfs_resolve_shortname(path, buf,
sizeof(buf));
sizeof (buf));
if (error != 0)
return (zfs_error(hdl, EZFS_NODEVICE,
msg));
@@ -2519,7 +2520,7 @@ zpool_vdev_fault(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
libzfs_handle_t *hdl = zhp->zpool_hdl;
(void) snprintf(msg, sizeof (msg),
dgettext(TEXT_DOMAIN, "cannot fault %llu"), (u_longlong_t)guid);
dgettext(TEXT_DOMAIN, "cannot fault %llu"), (u_longlong_t)guid);
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
zc.zc_guid = guid;
@@ -2554,7 +2555,7 @@ zpool_vdev_degrade(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
libzfs_handle_t *hdl = zhp->zpool_hdl;
(void) snprintf(msg, sizeof (msg),
dgettext(TEXT_DOMAIN, "cannot degrade %llu"), (u_longlong_t)guid);
dgettext(TEXT_DOMAIN, "cannot degrade %llu"), (u_longlong_t)guid);
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
zc.zc_guid = guid;
@@ -3215,7 +3216,7 @@ zpool_vdev_clear(zpool_handle_t *zhp, uint64_t guid)
(void) snprintf(msg, sizeof (msg),
dgettext(TEXT_DOMAIN, "cannot clear errors for %llx"),
(u_longlong_t)guid);
(u_longlong_t)guid);
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
zc.zc_guid = guid;
@@ -3460,7 +3461,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
*/
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK,
&value) == 0 && value) {
return strip_partition(hdl, path);
return (strip_partition(hdl, path));
}
} else {
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0);
@@ -3880,7 +3881,8 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
if (dsobj == 0) {
/* special case for the MOS */
(void) snprintf(pathname, len, "<metadata>:<0x%llx>", (longlong_t)obj);
(void) snprintf(pathname, len, "<metadata>:<0x%llx>",
(longlong_t)obj);
return;
}
@@ -3912,7 +3914,8 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
dsname, zc.zc_value);
}
} else {
(void) snprintf(pathname, len, "%s:<0x%llx>", dsname, (longlong_t)obj);
(void) snprintf(pathname, len, "%s:<0x%llx>", dsname,
(longlong_t)obj);
}
free(mntpnt);
}
@@ -4012,22 +4015,22 @@ zpool_label_disk_check(char *path)
int fd, err;
if ((fd = open(path, O_RDWR|O_DIRECT)) < 0)
return errno;
return (errno);
if ((err = efi_alloc_and_read(fd, &vtoc)) != 0) {
(void) close(fd);
return err;
return (err);
}
if (vtoc->efi_flags & EFI_GPT_PRIMARY_CORRUPT) {
efi_free(vtoc);
(void) close(fd);
return EIDRM;
return (EIDRM);
}
efi_free(vtoc);
(void) close(fd);
return 0;
return (0);
}
/*
@@ -4167,5 +4170,5 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, char *name)
return (zfs_error(hdl, EZFS_LABELFAILED, errbuf));
}
return 0;
return (0);
}
+18 -18
View File
@@ -617,8 +617,8 @@ libzfs_module_loaded(const char *module)
const char path_prefix[] = "/sys/module/";
char path[256];
memcpy(path, path_prefix, sizeof(path_prefix) - 1);
strcpy(path + sizeof(path_prefix) - 1, module);
memcpy(path, path_prefix, sizeof (path_prefix) - 1);
strcpy(path + sizeof (path_prefix) - 1, module);
return (access(path, F_OK) == 0);
}
@@ -652,12 +652,12 @@ libzfs_run_process(const char *path, char *argv[], int flags)
while ((rc = waitpid(pid, &status, 0)) == -1 &&
errno == EINTR);
if (rc < 0 || !WIFEXITED(status))
return -1;
return (-1);
return WEXITSTATUS(status);
return (WEXITSTATUS(status));
}
return -1;
return (-1);
}
int
@@ -666,9 +666,9 @@ libzfs_load_module(const char *module)
char *argv[4] = {"/sbin/modprobe", "-q", (char *)module, (char *)0};
if (libzfs_module_loaded(module))
return 0;
return (0);
return libzfs_run_process("/sbin/modprobe", argv, 0);
return (libzfs_run_process("/sbin/modprobe", argv, 0));
}
libzfs_handle_t *
@@ -678,8 +678,8 @@ libzfs_init(void)
if (libzfs_load_module("zfs") != 0) {
(void) fprintf(stderr, gettext("Failed to load ZFS module "
"stack.\nLoad the module manually by running "
"'insmod <location>/zfs.ko' as root.\n"));
"stack.\nLoad the module manually by running "
"'insmod <location>/zfs.ko' as root.\n"));
return (NULL);
}
@@ -689,11 +689,11 @@ libzfs_init(void)
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
(void) fprintf(stderr, gettext("Unable to open %s: %s.\n"),
ZFS_DEV, strerror(errno));
ZFS_DEV, strerror(errno));
if (errno == ENOENT)
(void) fprintf(stderr,
gettext("Verify the ZFS module stack is "
"loaded by running '/sbin/modprobe zfs'.\n"));
gettext("Verify the ZFS module stack is "
"loaded by running '/sbin/modprobe zfs'.\n"));
free(hdl);
return (NULL);
@@ -914,7 +914,7 @@ zfs_strcmp_shortname(char *name, char *cmp_name, int wholedisk)
if (wholedisk)
path_len = zfs_append_partition(path_name, MAXPATHLEN);
if ((path_len == cmp_len) && !strcmp(path_name, cmp_name)) {
if ((path_len == cmp_len) && strcmp(path_name, cmp_name) == 0) {
error = 0;
break;
}
@@ -957,7 +957,7 @@ zfs_strcmp_pathname(char *name, char *cmp, int wholedisk)
}
if (name[0] != '/')
return zfs_strcmp_shortname(name, cmp_name, wholedisk);
return (zfs_strcmp_shortname(name, cmp_name, wholedisk));
strncpy(path_name, name, MAXPATHLEN);
path_len = strlen(path_name);
@@ -1313,10 +1313,10 @@ str2shift(libzfs_handle_t *hdl, const char *buf)
*/
if (buf[1] == '\0' ||
(toupper(buf[0]) != 'B' &&
((toupper(buf[1]) == 'B' && buf[2] == '\0') ||
(toupper(buf[1]) == 'I' && toupper(buf[2]) == 'B' &&
buf[3] == '\0'))))
return (10*i);
((toupper(buf[1]) == 'B' && buf[2] == '\0') ||
(toupper(buf[1]) == 'I' && toupper(buf[2]) == 'B' &&
buf[3] == '\0'))))
return (10 * i);
if (hdl)
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,