diff options
Diffstat (limited to 'lib')
78 files changed, 708 insertions, 612 deletions
diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c index f4cf41712..a6dec404b 100644 --- a/lib/libefi/rdwr_efi.c +++ b/lib/libefi/rdwr_efi.c @@ -132,8 +132,8 @@ read_disk_info(int fd, diskaddr_t *capacity, uint_t *lbsize) int sector_size; unsigned long long capacity_size; - if (ioctl(fd, BLKSSZGET, §or_size) < 0) - return (-1); + if (ioctl(fd, BLKSSZGET, §or_size) < 0) + return (-1); if (ioctl(fd, BLKGETSIZE64, &capacity_size) < 0) return (-1); @@ -152,7 +152,7 @@ efi_get_info(int fd, struct dk_cinfo *dki_info) char *dev_path; int rval = 0; - memset(dki_info, 0, sizeof(*dki_info)); + memset(dki_info, 0, sizeof (*dki_info)); path = calloc(PATH_MAX, 1); if (path == NULL) @@ -182,44 +182,44 @@ efi_get_info(int fd, struct dk_cinfo *dki_info) strcpy(dki_info->dki_cname, "sd"); dki_info->dki_ctype = DKC_SCSI_CCS; rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu", - dki_info->dki_dname, - &dki_info->dki_partition); + dki_info->dki_dname, + &dki_info->dki_partition); } else if ((strncmp(dev_path, "/dev/hd", 7) == 0)) { strcpy(dki_info->dki_cname, "hd"); dki_info->dki_ctype = DKC_DIRECT; rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu", - dki_info->dki_dname, - &dki_info->dki_partition); + dki_info->dki_dname, + &dki_info->dki_partition); } else if ((strncmp(dev_path, "/dev/md", 7) == 0)) { strcpy(dki_info->dki_cname, "pseudo"); dki_info->dki_ctype = DKC_MD; rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu", - dki_info->dki_dname, - &dki_info->dki_partition); + dki_info->dki_dname, + &dki_info->dki_partition); } else if ((strncmp(dev_path, "/dev/vd", 7) == 0)) { strcpy(dki_info->dki_cname, "vd"); dki_info->dki_ctype = DKC_MD; rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu", - dki_info->dki_dname, - &dki_info->dki_partition); + dki_info->dki_dname, + &dki_info->dki_partition); } else if ((strncmp(dev_path, "/dev/dm-", 8) == 0)) { strcpy(dki_info->dki_cname, "pseudo"); dki_info->dki_ctype = DKC_VBD; rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9-]p%hu", - dki_info->dki_dname, - &dki_info->dki_partition); + dki_info->dki_dname, + &dki_info->dki_partition); } else if ((strncmp(dev_path, "/dev/ram", 8) == 0)) { strcpy(dki_info->dki_cname, "pseudo"); dki_info->dki_ctype = DKC_PCMCIA_MEM; rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu", - dki_info->dki_dname, - &dki_info->dki_partition); + dki_info->dki_dname, + &dki_info->dki_partition); } else if ((strncmp(dev_path, "/dev/loop", 9) == 0)) { strcpy(dki_info->dki_cname, "pseudo"); dki_info->dki_ctype = DKC_VBD; rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu", - dki_info->dki_dname, - &dki_info->dki_partition); + dki_info->dki_dname, + &dki_info->dki_partition); } else { strcpy(dki_info->dki_dname, "unknown"); strcpy(dki_info->dki_cname, "unknown"); @@ -395,10 +395,10 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc) */ if (read_disk_info(fd, &capacity, &lbsize) == -1) { if (efi_debug) - fprintf(stderr,"unable to read disk info: %d",errno); + fprintf(stderr, "unable to read disk info: %d", errno); errno = EIO; - return -1; + return (-1); } switch (cmd) { @@ -406,7 +406,7 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc) if (lbsize == 0) { if (efi_debug) (void) fprintf(stderr, "DKIOCGETEFI assuming " - "LBA %d bytes\n", DEV_BSIZE); + "LBA %d bytes\n", DEV_BSIZE); lbsize = DEV_BSIZE; } @@ -415,24 +415,24 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc) if (error == -1) { if (efi_debug) (void) fprintf(stderr, "DKIOCGETEFI lseek " - "error: %d\n", errno); - return error; + "error: %d\n", errno); + return (error); } error = read(fd, data, dk_ioc->dki_length); if (error == -1) { if (efi_debug) (void) fprintf(stderr, "DKIOCGETEFI read " - "error: %d\n", errno); - return error; + "error: %d\n", errno); + return (error); } if (error != dk_ioc->dki_length) { if (efi_debug) (void) fprintf(stderr, "DKIOCGETEFI short " - "read of %d bytes\n", error); + "read of %d bytes\n", error); errno = EIO; - return -1; + return (-1); } error = 0; break; @@ -441,43 +441,43 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc) if (lbsize == 0) { if (efi_debug) (void) fprintf(stderr, "DKIOCSETEFI unknown " - "LBA size\n"); + "LBA size\n"); errno = EIO; - return -1; + return (-1); } error = lseek(fd, dk_ioc->dki_lba * lbsize, SEEK_SET); if (error == -1) { if (efi_debug) (void) fprintf(stderr, "DKIOCSETEFI lseek " - "error: %d\n", errno); - return error; + "error: %d\n", errno); + return (error); } error = write(fd, data, dk_ioc->dki_length); if (error == -1) { if (efi_debug) (void) fprintf(stderr, "DKIOCSETEFI write " - "error: %d\n", errno); - return error; + "error: %d\n", errno); + return (error); } if (error != dk_ioc->dki_length) { if (efi_debug) (void) fprintf(stderr, "DKIOCSETEFI short " - "write of %d bytes\n", error); + "write of %d bytes\n", error); errno = EIO; - return -1; + return (-1); } /* Sync the new EFI table to disk */ error = fsync(fd); if (error == -1) - return error; + return (error); /* Ensure any local disk cache is also flushed */ if (ioctl(fd, BLKFLSBUF, 0) == -1) - return error; + return (error); error = 0; break; @@ -487,7 +487,7 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc) (void) fprintf(stderr, "unsupported ioctl()\n"); errno = EIO; - return -1; + return (-1); } #else dk_ioc->dki_data_64 = (uint64_t)(uintptr_t)data; @@ -497,7 +497,8 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc) return (error); } -int efi_rescan(int fd) +int +efi_rescan(int fd) { #if defined(__linux__) int retry = 5; @@ -507,7 +508,7 @@ int efi_rescan(int fd) while ((error = ioctl(fd, BLKRRPART)) != 0) { if (--retry == 0) { (void) fprintf(stderr, "the kernel failed to rescan " - "the partition table: %d\n", errno); + "the partition table: %d\n", errno); return (-1); } } @@ -548,7 +549,7 @@ check_label(int fd, dk_efi_t *dk_ioc) efi->efi_gpt_HeaderCRC32 = 0; len_t headerSize = (len_t)LE_32(efi->efi_gpt_HeaderSize); - if(headerSize < EFI_MIN_LABEL_SIZE || headerSize > EFI_LABEL_SIZE) { + if (headerSize < EFI_MIN_LABEL_SIZE || headerSize > EFI_LABEL_SIZE) { if (efi_debug) (void) fprintf(stderr, "Invalid EFI HeaderSize %llu. Assuming %d.\n", @@ -590,7 +591,7 @@ efi_read(int fd, struct dk_gpt *vtoc) * get the partition number for this file descriptor. */ if ((rval = efi_get_info(fd, &dki_info)) != 0) - return rval; + return (rval); if ((strncmp(dki_info.dki_cname, "pseudo", 7) == 0) && (strncmp(dki_info.dki_dname, "md", 3) == 0)) { @@ -608,8 +609,8 @@ efi_read(int fd, struct dk_gpt *vtoc) if (read_disk_info(fd, &capacity, &lbsize) == -1) { if (efi_debug) { (void) fprintf(stderr, - "unable to read disk info: %d", - errno); + "unable to read disk info: %d", + errno); } return (VT_EINVAL); } @@ -642,7 +643,7 @@ efi_read(int fd, struct dk_gpt *vtoc) } if (posix_memalign((void **)&dk_ioc.dki_data, - disk_info.dki_lbsize, label_len)) + disk_info.dki_lbsize, label_len)) return (VT_ERROR); memset(dk_ioc.dki_data, 0, label_len); @@ -1117,7 +1118,7 @@ efi_write(int fd, struct dk_gpt *vtoc) diskaddr_t lba_backup_gpt_hdr; if ((rval = efi_get_info(fd, &dki_info)) != 0) - return rval; + return (rval); /* check if we are dealing wih a metadevice */ if ((strncmp(dki_info.dki_cname, "pseudo", 7) == 0) && @@ -1156,7 +1157,7 @@ efi_write(int fd, struct dk_gpt *vtoc) */ lba_backup_gpt_hdr = vtoc->efi_last_u_lba + 1 + nblocks; if (posix_memalign((void **)&dk_ioc.dki_data, - vtoc->efi_lbasize, dk_ioc.dki_length)) + vtoc->efi_lbasize, dk_ioc.dki_length)) return (VT_ERROR); memset(dk_ioc.dki_data, 0, dk_ioc.dki_length); diff --git a/lib/libshare/libshare.c b/lib/libshare/libshare.c index 6b39ba872..6625a1b0c 100644 --- a/lib/libshare/libshare.c +++ b/lib/libshare/libshare.c @@ -64,7 +64,7 @@ register_fstype(const char *name, const sa_share_ops_t *ops) fstype = calloc(sizeof (sa_fstype_t), 1); if (fstype == NULL) - return NULL; + return (NULL); fstype->name = name; fstype->ops = ops; @@ -75,7 +75,7 @@ register_fstype(const char *name, const sa_share_ops_t *ops) fstype->next = fstypes; fstypes = fstype; - return fstype; + return (fstype); } sa_handle_t @@ -86,7 +86,7 @@ sa_init(int init_service) impl_handle = calloc(sizeof (struct sa_handle_impl), 1); if (impl_handle == NULL) - return NULL; + return (NULL); impl_handle->zfs_libhandle = libzfs_init(); @@ -243,30 +243,30 @@ update_zfs_shares_cb(zfs_handle_t *zhp, void *pcookie) if (type == ZFS_TYPE_FILESYSTEM && zfs_iter_filesystems(zhp, update_zfs_shares_cb, pcookie) != 0) { zfs_close(zhp); - return 1; + return (1); } if (type != ZFS_TYPE_FILESYSTEM) { zfs_close(zhp); - return 0; + return (0); } if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, sizeof (mountpoint), NULL, NULL, 0, B_FALSE) != 0) { zfs_close(zhp); - return 0; + return (0); } dataset = (char *)zfs_get_name(zhp); if (dataset == NULL) { zfs_close(zhp); - return 0; + return (0); } if (!zfs_is_mounted(zhp, NULL)) { zfs_close(zhp); - return 0; + return (0); } if ((udata->proto == NULL || strcmp(udata->proto, "nfs") == 0) && @@ -287,7 +287,7 @@ update_zfs_shares_cb(zfs_handle_t *zhp, void *pcookie) zfs_close(zhp); - return 0; + return (0); } static int @@ -298,7 +298,7 @@ update_zfs_share(sa_share_impl_t impl_share, const char *proto) update_cookie_t udata; if (impl_handle->zfs_libhandle == NULL) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); assert(impl_share->dataset != NULL); @@ -306,13 +306,13 @@ update_zfs_share(sa_share_impl_t impl_share, const char *proto) ZFS_TYPE_FILESYSTEM); if (zhp == NULL) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); udata.handle = impl_handle; udata.proto = proto; (void) update_zfs_shares_cb(zhp, &udata); - return SA_OK; + return (SA_OK); } static int @@ -321,14 +321,14 @@ update_zfs_shares(sa_handle_impl_t impl_handle, const char *proto) update_cookie_t udata; if (impl_handle->zfs_libhandle == NULL) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); udata.handle = impl_handle; udata.proto = proto; (void) zfs_iter_root(impl_handle->zfs_libhandle, update_zfs_shares_cb, &udata); - return SA_OK; + return (SA_OK); } static int @@ -351,7 +351,7 @@ process_share(sa_handle_impl_t impl_handle, sa_share_impl_t impl_share, if (impl_share == NULL) { if (lstat(pathname, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) - return SA_BAD_PATH; + return (SA_BAD_PATH); impl_share = alloc_share(pathname); @@ -421,7 +421,7 @@ err: free_share(impl_share); } - return rc; + return (rc); } void @@ -487,13 +487,13 @@ find_share(sa_handle_impl_t impl_handle, const char *sharepath) impl_share = impl_share->next; } - return impl_share; + return (impl_share); } sa_share_t sa_find_share(sa_handle_t handle, char *sharepath) { - return (sa_share_t)find_share((sa_handle_impl_t)handle, sharepath); + return ((sa_share_t)find_share((sa_handle_impl_t)handle, sharepath)); } int @@ -715,16 +715,16 @@ sa_parse_legacy_options(sa_group_t group, char *options, char *proto) continue; } - return fstype->ops->validate_shareopts(options); + return (fstype->ops->validate_shareopts(options)); } - return SA_INVALID_PROTOCOL; + return (SA_INVALID_PROTOCOL); } boolean_t sa_needs_refresh(sa_handle_t handle) { - return B_TRUE; + return (B_TRUE); } libzfs_handle_t * @@ -733,9 +733,9 @@ sa_get_zfs_handle(sa_handle_t handle) sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle; if (impl_handle == NULL) - return NULL; + return (NULL); - return impl_handle->zfs_libhandle; + return (impl_handle->zfs_libhandle); } static sa_share_impl_t @@ -746,13 +746,13 @@ alloc_share(const char *sharepath) impl_share = calloc(sizeof (struct sa_share_impl), 1); if (impl_share == NULL) - return NULL; + return (NULL); impl_share->sharepath = strdup(sharepath); if (impl_share->sharepath == NULL) { free(impl_share); - return NULL; + return (NULL); } impl_share->fsinfo = calloc(sizeof (sa_share_fsinfo_t), fstypes_count); @@ -760,10 +760,10 @@ alloc_share(const char *sharepath) if (impl_share->fsinfo == NULL) { free(impl_share->sharepath); free(impl_share); - return NULL; + return (NULL); } - return impl_share; + return (impl_share); } static void @@ -799,8 +799,8 @@ sa_zfs_process_share(sa_handle_t handle, sa_group_t group, sa_share_t share, shareopts, sourcestr, dataset); #endif - return process_share(impl_handle, impl_share, mountpoint, NULL, - proto, shareopts, NULL, dataset, B_FALSE); + return (process_share(impl_handle, impl_share, mountpoint, NULL, + proto, shareopts, NULL, dataset, B_FALSE)); } void diff --git a/lib/libshare/libshare_impl.h b/lib/libshare/libshare_impl.h index dfcec2ff9..18d619b10 100644 --- a/lib/libshare/libshare_impl.h +++ b/lib/libshare/libshare_impl.h @@ -43,7 +43,7 @@ typedef struct sa_share_impl { sa_share_fsinfo_t *fsinfo; /* per-fstype information */ } *sa_share_impl_t; -#define FSINFO(impl_share, fstype) (&(impl_share->fsinfo[fstype->fsinfo_index])) +#define FSINFO(impl_share, fstype) (&(impl_share->fsinfo[fstype->fsinfo_index])) typedef struct sa_share_ops { int (*enable_share)(sa_share_impl_t share); diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 00ba0f621..d1b207e65 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -50,7 +50,7 @@ typedef int (*nfs_shareopt_callback_t)(const char *opt, const char *value, typedef int (*nfs_host_callback_t)(const char *sharepath, const char *host, const char *security, const char *access, void *cookie); -/** +/* * Invokes the specified callback function for each Solaris share option * listed in the specified string. */ @@ -62,12 +62,12 @@ foreach_nfs_shareopt(const char *shareopts, int was_nul, rc; if (shareopts == NULL) - return SA_OK; + return (SA_OK); shareopts_dup = strdup(shareopts); if (shareopts_dup == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); opt = shareopts_dup; was_nul = 0; @@ -95,7 +95,7 @@ foreach_nfs_shareopt(const char *shareopts, if (rc != SA_OK) { free(shareopts_dup); - return rc; + return (rc); } } @@ -107,7 +107,7 @@ foreach_nfs_shareopt(const char *shareopts, free(shareopts_dup); - return 0; + return (0); } typedef struct nfs_host_cookie_s { @@ -117,7 +117,7 @@ typedef struct nfs_host_cookie_s { const char *security; } nfs_host_cookie_t; -/** +/* * Helper function for foreach_nfs_host. This function checks whether the * current share option is a host specification and invokes a callback * function with information about the host. @@ -146,7 +146,7 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie) host_dup = strdup(value); if (host_dup == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); host = host_dup; @@ -163,7 +163,7 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie) if (rc != SA_OK) { free(host_dup); - return rc; + return (rc); } host = next; @@ -172,10 +172,10 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie) free(host_dup); } - return SA_OK; + return (SA_OK); } -/** +/* * Invokes a callback function for all NFS hosts that are set for a share. */ static int @@ -196,7 +196,7 @@ foreach_nfs_host(sa_share_impl_t impl_share, nfs_host_callback_t callback, &udata); } -/** +/* * Converts a Solaris NFS host specification to its Linux equivalent. */ static int @@ -217,13 +217,13 @@ get_linux_hostspec(const char *solaris_hostspec, char **plinux_hostspec) } if (*plinux_hostspec == NULL) { - return SA_NO_MEMORY; + return (SA_NO_MEMORY); } - return SA_OK; + return (SA_OK); } -/** +/* * Used internally by nfs_enable_share to enable sharing for a single host. */ static int @@ -281,12 +281,12 @@ nfs_enable_share_one(const char *sharepath, const char *host, free(opts); if (rc < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); else - return SA_OK; + return (SA_OK); } -/** +/* * Adds a Linux share option to an array of NFS options. */ static int @@ -302,7 +302,7 @@ add_linux_shareopt(char **plinux_opts, const char *key, const char *value) (value ? 1 + strlen(value) : 0) + 1); if (new_linux_opts == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); new_linux_opts[len] = '\0'; @@ -318,10 +318,10 @@ add_linux_shareopt(char **plinux_opts, const char *key, const char *value) *plinux_opts = new_linux_opts; - return SA_OK; + return (SA_OK); } -/** +/* * Validates and converts a single Solaris share option to its Linux * equivalent. */ @@ -333,15 +333,15 @@ get_linux_shareopts_cb(const char *key, const char *value, void *cookie) /* host-specific options, these are taken care of elsewhere */ if (strcmp(key, "ro") == 0 || strcmp(key, "rw") == 0 || strcmp(key, "sec") == 0) - return SA_OK; + return (SA_OK); if (strcmp(key, "anon") == 0) key = "anonuid"; - if (strcmp(key, "root_mapping") == 0) { - (void) add_linux_shareopt(plinux_opts, "root_squash", NULL); - key = "anonuid"; - } + if (strcmp(key, "root_mapping") == 0) { + (void) add_linux_shareopt(plinux_opts, "root_squash", NULL); + key = "anonuid"; + } if (strcmp(key, "nosub") == 0) key = "subtree_check"; @@ -364,15 +364,15 @@ get_linux_shareopts_cb(const char *key, const char *value, void *cookie) strcmp(key, "all_squash") != 0 && strcmp(key, "no_all_squash") != 0 && strcmp(key, "fsid") != 0 && strcmp(key, "anonuid") != 0 && strcmp(key, "anongid") != 0) { - return SA_SYNTAX_ERR; + return (SA_SYNTAX_ERR); } (void) add_linux_shareopt(plinux_opts, key, value); - return SA_OK; + return (SA_OK); } -/** +/* * Takes a string containing Solaris share options (e.g. "sync,no_acl") and * converts them to a NULL-terminated array of Linux NFS options. */ @@ -390,17 +390,18 @@ get_linux_shareopts(const char *shareopts, char **plinux_opts) (void) add_linux_shareopt(plinux_opts, "no_root_squash", NULL); (void) add_linux_shareopt(plinux_opts, "mountpoint", NULL); - rc = foreach_nfs_shareopt(shareopts, get_linux_shareopts_cb, plinux_opts); + rc = foreach_nfs_shareopt(shareopts, get_linux_shareopts_cb, + plinux_opts); if (rc != SA_OK) { free(*plinux_opts); *plinux_opts = NULL; } - return rc; + return (rc); } -/** +/* * Enables NFS sharing for the specified share. */ static int @@ -410,27 +411,27 @@ nfs_enable_share(sa_share_impl_t impl_share) int rc; if (!nfs_available()) { - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); } shareopts = FSINFO(impl_share, nfs_fstype)->shareopts; if (shareopts == NULL) - return SA_OK; + return (SA_OK); rc = get_linux_shareopts(shareopts, &linux_opts); if (rc != SA_OK) - return rc; + return (rc); rc = foreach_nfs_host(impl_share, nfs_enable_share_one, linux_opts); free(linux_opts); - return rc; + return (rc); } -/** +/* * Used internally by nfs_disable_share to disable sharing for a single host. */ static int @@ -471,12 +472,12 @@ nfs_disable_share_one(const char *sharepath, const char *host, free(hostpath); if (rc < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); else - return SA_OK; + return (SA_OK); } -/** +/* * Disables NFS sharing for the specified share. */ static int @@ -487,13 +488,13 @@ nfs_disable_share(sa_share_impl_t impl_share) * The share can't possibly be active, so nothing * needs to be done to disable it. */ - return SA_OK; + return (SA_OK); } - return foreach_nfs_host(impl_share, nfs_disable_share_one, NULL); + return (foreach_nfs_host(impl_share, nfs_disable_share_one, NULL)); } -/** +/* * Checks whether the specified NFS share options are syntactically correct. */ static int @@ -505,14 +506,14 @@ nfs_validate_shareopts(const char *shareopts) rc = get_linux_shareopts(shareopts, &linux_opts); if (rc != SA_OK) - return rc; + return (rc); free(linux_opts); - return SA_OK; + return (SA_OK); } -/** +/* * Checks whether a share is currently active. */ static boolean_t @@ -523,17 +524,17 @@ nfs_is_share_active(sa_share_impl_t impl_share) FILE *nfs_exportfs_temp_fp; if (!nfs_available()) - return B_FALSE; + return (B_FALSE); nfs_exportfs_temp_fp = fdopen(dup(nfs_exportfs_temp_fd), "r"); if (nfs_exportfs_temp_fp == NULL || fseek(nfs_exportfs_temp_fp, 0, SEEK_SET) < 0) { fclose(nfs_exportfs_temp_fp); - return B_FALSE; + return (B_FALSE); } - while (fgets(line, sizeof(line), nfs_exportfs_temp_fp) != NULL) { + while (fgets(line, sizeof (line), nfs_exportfs_temp_fp) != NULL) { /* * exportfs uses separate lines for the share path * and the export options when the share path is longer @@ -564,16 +565,16 @@ nfs_is_share_active(sa_share_impl_t impl_share) if (strcmp(line, impl_share->sharepath) == 0) { fclose(nfs_exportfs_temp_fp); - return B_TRUE; + return (B_TRUE); } } fclose(nfs_exportfs_temp_fp); - return B_FALSE; + return (B_FALSE); } -/** +/* * Called to update a share's options. A share's options might be out of * date if the share was loaded from disk (i.e. /etc/dfs/sharetab) and the * "sharenfs" dataset property has changed in the meantime. This function @@ -604,7 +605,7 @@ nfs_update_shareopts(sa_share_impl_t impl_share, const char *resource, shareopts_dup = strdup(shareopts); if (shareopts_dup == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); if (old_shareopts != NULL) free(old_shareopts); @@ -614,10 +615,10 @@ nfs_update_shareopts(sa_share_impl_t impl_share, const char *resource, if (needs_reshare) nfs_enable_share(impl_share); - return SA_OK; + return (SA_OK); } -/** +/* * Clears a share's NFS options. Used by libshare to * clean up shares that are about to be free()'d. */ @@ -666,7 +667,7 @@ nfs_check_exportfs(void) nfs_exportfs_temp_fd = mkstemp(nfs_exportfs_tempfile); if (nfs_exportfs_temp_fd < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); unlink(nfs_exportfs_tempfile); @@ -677,26 +678,25 @@ nfs_check_exportfs(void) if (pid < 0) { (void) close(nfs_exportfs_temp_fd); nfs_exportfs_temp_fd = -1; - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); } if (pid > 0) { - while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR) - ; /* empty loop body */ + while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR); if (rc <= 0) { (void) close(nfs_exportfs_temp_fd); nfs_exportfs_temp_fd = -1; - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); } if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { (void) close(nfs_exportfs_temp_fd); nfs_exportfs_temp_fd = -1; - return SA_CONFIG_ERR; + return (SA_CONFIG_ERR); } - return SA_OK; + return (SA_OK); } /* child */ @@ -724,10 +724,10 @@ nfs_available(void) if (nfs_exportfs_temp_fd == -1) (void) nfs_check_exportfs(); - return (nfs_exportfs_temp_fd != -1) ? B_TRUE : B_FALSE; + return ((nfs_exportfs_temp_fd != -1) ? B_TRUE : B_FALSE); } -/** +/* * Initializes the NFS functionality of libshare. */ void diff --git a/lib/libshare/smb.c b/lib/libshare/smb.c index a545bfb0f..1ac1a8d27 100644 --- a/lib/libshare/smb.c +++ b/lib/libshare/smb.c @@ -26,7 +26,7 @@ * * This is an addition to the zfs device driver to add, modify and remove SMB * shares using the 'net share' command that comes with Samba. - + * * TESTING * Make sure that samba listens to 'localhost' (127.0.0.1) and that the options * 'usershare max shares' and 'usershare owner only' have been rewied/set @@ -64,7 +64,7 @@ static boolean_t smb_available(void); static sa_fstype_t *smb_fstype; -/** +/* * Retrieve the list of SMB shares. */ static int @@ -83,7 +83,7 @@ smb_retrieve_shares(void) /* opendir(), stat() */ shares_dir = opendir(SHARE_DIR); if (shares_dir == NULL) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); /* Go through the directory, looking for shares */ while ((directory = readdir(shares_dir))) { @@ -91,7 +91,7 @@ smb_retrieve_shares(void) continue; snprintf(file_path, sizeof (file_path), - "%s/%s", SHARE_DIR, directory->d_name); + "%s/%s", SHARE_DIR, directory->d_name); if (stat(file_path, &eStat) == -1) { rc = SA_SYSTEM_ERR; @@ -108,17 +108,17 @@ smb_retrieve_shares(void) name = strdup(directory->d_name); if (name == NULL) { - rc = SA_NO_MEMORY; - goto out; + rc = SA_NO_MEMORY; + goto out; } - while (fgets(line, sizeof(line), share_file_fp)) { + while (fgets(line, sizeof (line), share_file_fp)) { if (line[0] == '#') continue; /* Trim trailing new-line character(s). */ while (line[strlen(line) - 1] == '\r' || - line[strlen(line) - 1] == '\n') + line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = '\0'; /* Split the line in two, separated by '=' */ @@ -155,24 +155,25 @@ smb_retrieve_shares(void) strncpy(shares->name, name, sizeof (shares->name)); - shares->name [sizeof(shares->name)-1] = '\0'; + shares->name [sizeof (shares->name) - 1] = '\0'; strncpy(shares->path, path, - sizeof (shares->path)); - shares->path [sizeof(shares->path)-1] = '\0'; + sizeof (shares->path)); + shares->path [sizeof (shares->path) - 1] = '\0'; strncpy(shares->comment, comment, - sizeof (shares->comment)); - shares->comment[sizeof(shares->comment)-1]='\0'; + sizeof (shares->comment)); + shares->comment[sizeof (shares->comment)-1] = + '\0'; shares->guest_ok = atoi(guest_ok); shares->next = new_shares; new_shares = shares; - name = NULL; - path = NULL; - comment = NULL; + name = NULL; + path = NULL; + comment = NULL; guest_ok = NULL; } } @@ -190,10 +191,10 @@ out: smb_shares = new_shares; - return rc; + return (rc); } -/** +/* * Used internally by smb_enable_share to enable sharing for a single host. */ static int @@ -204,8 +205,8 @@ smb_enable_share_one(const char *sharename, const char *sharepath) int rc; /* Support ZFS share name regexp '[[:alnum:]_-.: ]' */ - strncpy(name, sharename, sizeof(name)); - name [sizeof(name)-1] = '\0'; + strncpy(name, sharename, sizeof (name)); + name [sizeof (name)-1] = '\0'; pos = name; while (*pos != '\0') { @@ -220,32 +221,34 @@ smb_enable_share_one(const char *sharename, const char *sharepath) ++pos; } - /* CMD: net -S NET_CMD_ARG_HOST usershare add Test1 /share/Test1 \ - * "Comment" "Everyone:F" */ - snprintf(comment, sizeof(comment), "Comment: %s", sharepath); - - argv[0] = NET_CMD_PATH; - argv[1] = (char*)"-S"; - argv[2] = NET_CMD_ARG_HOST; - argv[3] = (char*)"usershare"; - argv[4] = (char*)"add"; - argv[5] = (char*)name; - argv[6] = (char*)sharepath; - argv[7] = (char*)comment; + /* + * CMD: net -S NET_CMD_ARG_HOST usershare add Test1 /share/Test1 \ + * "Comment" "Everyone:F" + */ + snprintf(comment, sizeof (comment), "Comment: %s", sharepath); + + argv[0] = NET_CMD_PATH; + argv[1] = (char *)"-S"; + argv[2] = NET_CMD_ARG_HOST; + argv[3] = (char *)"usershare"; + argv[4] = (char *)"add"; + argv[5] = (char *)name; + argv[6] = (char *)sharepath; + argv[7] = (char *)comment; argv[8] = "Everyone:F"; argv[9] = NULL; rc = libzfs_run_process(argv[0], argv, 0); if (rc < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); /* Reload the share file */ (void) smb_retrieve_shares(); - return SA_OK; + return (SA_OK); } -/** +/* * Enables SMB sharing for the specified share. */ static int @@ -254,20 +257,21 @@ smb_enable_share(sa_share_impl_t impl_share) char *shareopts; if (!smb_available()) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); shareopts = FSINFO(impl_share, smb_fstype)->shareopts; if (shareopts == NULL) /* on/off */ - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); if (strcmp(shareopts, "off") == 0) - return SA_OK; + return (SA_OK); /* Magic: Enable (i.e., 'create new') share */ - return smb_enable_share_one(impl_share->dataset, impl_share->sharepath); + return (smb_enable_share_one(impl_share->dataset, + impl_share->sharepath)); } -/** +/* * Used internally by smb_disable_share to disable sharing for a single host. */ static int @@ -278,21 +282,21 @@ smb_disable_share_one(const char *sharename) /* CMD: net -S NET_CMD_ARG_HOST usershare delete Test1 */ argv[0] = NET_CMD_PATH; - argv[1] = (char*)"-S"; + argv[1] = (char *)"-S"; argv[2] = NET_CMD_ARG_HOST; - argv[3] = (char*)"usershare"; - argv[4] = (char*)"delete"; + argv[3] = (char *)"usershare"; + argv[4] = (char *)"delete"; argv[5] = strdup(sharename); argv[6] = NULL; rc = libzfs_run_process(argv[0], argv, 0); if (rc < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); else - return SA_OK; + return (SA_OK); } -/** +/* * Disables SMB sharing for the specified share. */ static int @@ -305,20 +309,20 @@ smb_disable_share(sa_share_impl_t impl_share) * The share can't possibly be active, so nothing * needs to be done to disable it. */ - return SA_OK; + return (SA_OK); } while (shares != NULL) { if (strcmp(impl_share->sharepath, shares->path) == 0) - return smb_disable_share_one(shares->name); + return (smb_disable_share_one(shares->name)); shares = shares->next; } - return SA_OK; + return (SA_OK); } -/** +/* * Checks whether the specified SMB share options are syntactically correct. */ static int @@ -326,34 +330,34 @@ smb_validate_shareopts(const char *shareopts) { /* TODO: Accept 'name' and sec/acl (?) */ if ((strcmp(shareopts, "off") == 0) || (strcmp(shareopts, "on") == 0)) - return SA_OK; + return (SA_OK); - return SA_SYNTAX_ERR; + return (SA_SYNTAX_ERR); } -/** +/* * Checks whether a share is currently active. */ static boolean_t smb_is_share_active(sa_share_impl_t impl_share) { if (!smb_available()) - return B_FALSE; + return (B_FALSE); /* Retrieve the list of (possible) active shares */ smb_retrieve_shares(); while (smb_shares != NULL) { if (strcmp(impl_share->sharepath, smb_shares->path) == 0) - return B_TRUE; + return (B_TRUE); smb_shares = smb_shares->next; } - return B_FALSE; + return (B_FALSE); } -/** +/* * Called to update a share's options. A share's options might be out of * date if the share was loaded from disk and the "sharesmb" dataset * property has changed in the meantime. This function also takes care @@ -367,8 +371,8 @@ smb_update_shareopts(sa_share_impl_t impl_share, const char *resource, boolean_t needs_reshare = B_FALSE; char *old_shareopts; - if(!impl_share) - return SA_SYSTEM_ERR; + if (!impl_share) + return (SA_SYSTEM_ERR); FSINFO(impl_share, smb_fstype)->active = smb_is_share_active(impl_share); @@ -384,7 +388,7 @@ smb_update_shareopts(sa_share_impl_t impl_share, const char *resource, shareopts_dup = strdup(shareopts); if (shareopts_dup == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); if (old_shareopts != NULL) free(old_shareopts); @@ -394,10 +398,10 @@ smb_update_shareopts(sa_share_impl_t impl_share, const char *resource, if (needs_reshare) smb_enable_share(impl_share); - return SA_OK; + return (SA_OK); } -/** +/* * Clears a share's SMB options. Used by libshare to * clean up shares that are about to be free()'d. */ @@ -427,15 +431,15 @@ smb_available(void) if (lstat(SHARE_DIR, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) - return B_FALSE; + return (B_FALSE); if (access(NET_CMD_PATH, F_OK) != 0) - return B_FALSE; + return (B_FALSE); - return B_TRUE; + return (B_TRUE); } -/** +/* * Initializes the SMB functionality of libshare. */ void diff --git a/lib/libshare/smb.h b/lib/libshare/smb.h index f5ac83ace..7a0c0fd16 100644 --- a/lib/libshare/smb.h +++ b/lib/libshare/smb.h @@ -28,12 +28,12 @@ * references are hard to find. */ -#define SMB_NAME_MAX 255 -#define SMB_COMMENT_MAX 255 +#define SMB_NAME_MAX 255 +#define SMB_COMMENT_MAX 255 -#define SHARE_DIR "/var/lib/samba/usershares" -#define NET_CMD_PATH "/usr/bin/net" -#define NET_CMD_ARG_HOST "127.0.0.1" +#define SHARE_DIR "/var/lib/samba/usershares" +#define NET_CMD_PATH "/usr/bin/net" +#define NET_CMD_ARG_HOST "127.0.0.1" typedef struct smb_share_s { char name[SMB_NAME_MAX]; /* Share name */ diff --git a/lib/libspl/asm-generic/atomic.c b/lib/libspl/asm-generic/atomic.c index a3223eadc..f5eb4f34b 100644 --- a/lib/libspl/asm-generic/atomic.c +++ b/lib/libspl/asm-generic/atomic.c @@ -40,7 +40,7 @@ pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER; * Theses are the void returning variants */ -#define ATOMIC_INC(name, type) \ +#define ATOMIC_INC(name, type) \ void atomic_inc_##name(volatile type *target) \ { \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ @@ -59,7 +59,7 @@ ATOMIC_INC(ulong, ulong_t) ATOMIC_INC(64, uint64_t) -#define ATOMIC_DEC(name, type) \ +#define ATOMIC_DEC(name, type) \ void atomic_dec_##name(volatile type *target) \ { \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ @@ -78,7 +78,7 @@ ATOMIC_DEC(ulong, ulong_t) ATOMIC_DEC(64, uint64_t) -#define ATOMIC_ADD(name, type1, type2) \ +#define ATOMIC_ADD(name, type1, type2) \ void atomic_add_##name(volatile type1 *target, type2 bits) \ { \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ @@ -95,7 +95,8 @@ ATOMIC_ADD(int, uint_t, int) ATOMIC_ADD(long, ulong_t, long) ATOMIC_ADD(64, uint64_t, int64_t) -void atomic_add_ptr(volatile void *target, ssize_t bits) +void +atomic_add_ptr(volatile void *target, ssize_t bits) { VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); *(caddr_t *)target += bits; @@ -103,7 +104,7 @@ void atomic_add_ptr(volatile void *target, ssize_t bits) } -#define ATOMIC_SUB(name, type1, type2) \ +#define ATOMIC_SUB(name, type1, type2) \ void atomic_sub_##name(volatile type1 *target, type2 bits) \ { \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ @@ -120,7 +121,8 @@ ATOMIC_SUB(int, uint_t, int) ATOMIC_SUB(long, ulong_t, long) ATOMIC_SUB(64, uint64_t, int64_t) -void atomic_sub_ptr(volatile void *target, ssize_t bits) +void +atomic_sub_ptr(volatile void *target, ssize_t bits) { VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); *(caddr_t *)target -= bits; @@ -128,7 +130,7 @@ void atomic_sub_ptr(volatile void *target, ssize_t bits) } -#define ATOMIC_OR(name, type) \ +#define ATOMIC_OR(name, type) \ void atomic_or_##name(volatile type *target, type bits) \ { \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ @@ -146,7 +148,7 @@ ATOMIC_OR(ulong, ulong_t) ATOMIC_OR(64, uint64_t) -#define ATOMIC_AND(name, type) \ +#define ATOMIC_AND(name, type) \ void atomic_and_##name(volatile type *target, type bits) \ { \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ @@ -168,14 +170,14 @@ ATOMIC_AND(64, uint64_t) * New value returning variants */ -#define ATOMIC_INC_NV(name, type) \ +#define ATOMIC_INC_NV(name, type) \ type atomic_inc_##name##_nv(volatile type *target) \ { \ type rc; \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ rc = (++(*target)); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ - return rc; \ + return (rc); \ } ATOMIC_INC_NV(long, unsigned long) @@ -189,14 +191,14 @@ ATOMIC_INC_NV(ulong, ulong_t) ATOMIC_INC_NV(64, uint64_t) -#define ATOMIC_DEC_NV(name, type) \ +#define ATOMIC_DEC_NV(name, type) \ type atomic_dec_##name##_nv(volatile type *target) \ { \ type rc; \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ rc = (--(*target)); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ - return rc; \ + return (rc); \ } ATOMIC_DEC_NV(long, unsigned long) @@ -210,14 +212,14 @@ ATOMIC_DEC_NV(ulong, ulong_t) ATOMIC_DEC_NV(64, uint64_t) -#define ATOMIC_ADD_NV(name, type1, type2) \ +#define ATOMIC_ADD_NV(name, type1, type2) \ type1 atomic_add_##name##_nv(volatile type1 *target, type2 bits)\ { \ type1 rc; \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ rc = (*target += bits); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ - return rc; \ + return (rc); \ } ATOMIC_ADD_NV(8, uint8_t, int8_t) @@ -229,7 +231,8 @@ ATOMIC_ADD_NV(int, uint_t, int) ATOMIC_ADD_NV(long, ulong_t, long) ATOMIC_ADD_NV(64, uint64_t, int64_t) -void *atomic_add_ptr_nv(volatile void *target, ssize_t bits) +void * +atomic_add_ptr_nv(volatile void *target, ssize_t bits) { void *ptr; @@ -237,18 +240,18 @@ void *atomic_add_ptr_nv(volatile void *target, ssize_t bits) ptr = (*(caddr_t *)target += bits); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); - return ptr; + return (ptr); } -#define ATOMIC_SUB_NV(name, type1, type2) \ +#define ATOMIC_SUB_NV(name, type1, type2) \ type1 atomic_sub_##name##_nv(volatile type1 *target, type2 bits)\ { \ type1 rc; \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ rc = (*target -= bits); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ - return rc; \ + return (rc); \ } ATOMIC_SUB_NV(8, uint8_t, int8_t) @@ -260,7 +263,8 @@ ATOMIC_SUB_NV(int, uint_t, int) ATOMIC_SUB_NV(long, ulong_t, long) ATOMIC_SUB_NV(64, uint64_t, int64_t) -void *atomic_sub_ptr_nv(volatile void *target, ssize_t bits) +void * +atomic_sub_ptr_nv(volatile void *target, ssize_t bits) { void *ptr; @@ -268,18 +272,18 @@ void *atomic_sub_ptr_nv(volatile void *target, ssize_t bits) ptr = (*(caddr_t *)target -= bits); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); - return ptr; + return (ptr); } -#define ATOMIC_OR_NV(name, type) \ +#define ATOMIC_OR_NV(name, type) \ type atomic_or_##name##_nv(volatile type *target, type bits) \ { \ type rc; \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ rc = (*target |= bits); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ - return rc; \ + return (rc); \ } ATOMIC_OR_NV(long, unsigned long) @@ -293,14 +297,14 @@ ATOMIC_OR_NV(ulong, ulong_t) ATOMIC_OR_NV(64, uint64_t) -#define ATOMIC_AND_NV(name, type) \ +#define ATOMIC_AND_NV(name, type) \ type atomic_and_##name##_nv(volatile type *target, type bits) \ { \ type rc; \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ rc = (*target &= bits); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ - return rc; \ + return (rc); \ } ATOMIC_AND_NV(long, unsigned long) @@ -318,7 +322,7 @@ ATOMIC_AND_NV(64, uint64_t) * If *arg1 == arg2, set *arg1 = arg3; return old value */ -#define ATOMIC_CAS(name, type) \ +#define ATOMIC_CAS(name, type) \ type atomic_cas_##name(volatile type *target, type arg1, type arg2) \ { \ type old; \ @@ -327,7 +331,7 @@ ATOMIC_AND_NV(64, uint64_t) if (old == arg1) \ *target = arg2; \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ - return old; \ + return (old); \ } ATOMIC_CAS(8, uint8_t) @@ -339,17 +343,18 @@ ATOMIC_CAS(uint, uint_t) ATOMIC_CAS(ulong, ulong_t) ATOMIC_CAS(64, uint64_t) -void *atomic_cas_ptr(volatile void *target, void *arg1, void *arg2) +void * +atomic_cas_ptr(volatile void *target, void *arg1, void *arg2) { void *old; VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); old = *(void **)target; - if (old == arg1) - *(void **)target = arg2; + if (old == arg1) + *(void **)target = arg2; VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); - return old; + return (old); } @@ -357,7 +362,7 @@ void *atomic_cas_ptr(volatile void *target, void *arg1, void *arg2) * Swap target and return old value */ -#define ATOMIC_SWAP(name, type) \ +#define ATOMIC_SWAP(name, type) \ type atomic_swap_##name(volatile type *target, type bits) \ { \ type old; \ @@ -365,7 +370,7 @@ void *atomic_cas_ptr(volatile void *target, void *arg1, void *arg2) old = *target; \ *target = bits; \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ - return old; \ + return (old); \ } ATOMIC_SWAP(8, uint8_t) @@ -377,7 +382,8 @@ ATOMIC_SWAP(uint, uint_t) ATOMIC_SWAP(ulong, ulong_t) ATOMIC_SWAP(64, uint64_t) -void *atomic_swap_ptr(volatile void *target, void *bits) +void * +atomic_swap_ptr(volatile void *target, void *bits) { void *old; @@ -386,11 +392,12 @@ void *atomic_swap_ptr(volatile void *target, void *bits) *(void **)target = bits; VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); - return old; + return (old); } -int atomic_set_long_excl(volatile ulong_t *target, uint_t value) +int +atomic_set_long_excl(volatile ulong_t *target, uint_t value) { ulong_t bit; @@ -398,15 +405,16 @@ int atomic_set_long_excl(volatile ulong_t *target, uint_t value) bit = (1UL << value); if ((*target & bit) != 0) { VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); - return -1; + return (-1); } *target |= bit; VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); - return 0; + return (0); } -int atomic_clear_long_excl(volatile ulong_t *target, uint_t value) +int +atomic_clear_long_excl(volatile ulong_t *target, uint_t value) { ulong_t bit; @@ -414,67 +422,78 @@ int atomic_clear_long_excl(volatile ulong_t *target, uint_t value) bit = (1UL << value); if ((*target & bit) != 0) { VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); - return -1; + return (-1); } *target &= ~bit; VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); - return 0; + return (0); } -void membar_enter(void) +void +membar_enter(void) { /* XXX - Implement me */ } -void membar_exit(void) +void +membar_exit(void) { /* XXX - Implement me */ } -void membar_producer(void) +void +membar_producer(void) { /* XXX - Implement me */ } -void membar_consumer(void) +void +membar_consumer(void) { /* XXX - Implement me */ } /* Legacy kernel interfaces; they will go away (eventually). */ -uint8_t cas8(uint8_t *target, uint8_t arg1, uint8_t arg2) +uint8_t +cas8(uint8_t *target, uint8_t arg1, uint8_t arg2) { - return atomic_cas_8(target, arg1, arg2); + return (atomic_cas_8(target, arg1, arg2)); } -uint32_t cas32(uint32_t *target, uint32_t arg1, uint32_t arg2) +uint32_t +cas32(uint32_t *target, uint32_t arg1, uint32_t arg2) { - return atomic_cas_32(target, arg1, arg2); + return (atomic_cas_32(target, arg1, arg2)); } -uint64_t cas64(uint64_t *target, uint64_t arg1, uint64_t arg2) +uint64_t +cas64(uint64_t *target, uint64_t arg1, uint64_t arg2) { - return atomic_cas_64(target, arg1, arg2); + return (atomic_cas_64(target, arg1, arg2)); } -ulong_t caslong(ulong_t *target, ulong_t arg1, ulong_t arg2) +ulong_t +caslong(ulong_t *target, ulong_t arg1, ulong_t arg2) { - return atomic_cas_ulong(target, arg1, arg2); + return (atomic_cas_ulong(target, arg1, arg2)); } -void *casptr(void *target, void *arg1, void *arg2) +void * +casptr(void *target, void *arg1, void *arg2) { - return atomic_cas_ptr(target, arg1, arg2); + return (atomic_cas_ptr(target, arg1, arg2)); } -void atomic_and_long(ulong_t *target, ulong_t bits) +void +atomic_and_long(ulong_t *target, ulong_t bits) { - return atomic_and_ulong(target, bits); + return (atomic_and_ulong(target, bits)); } -void atomic_or_long(ulong_t *target, ulong_t bits) +void +atomic_or_long(ulong_t *target, ulong_t bits) { - return atomic_or_ulong(target, bits); + return (atomic_or_ulong(target, bits)); } diff --git a/lib/libspl/getexecname.c b/lib/libspl/getexecname.c index c564eed05..478351ce7 100644 --- a/lib/libspl/getexecname.c +++ b/lib/libspl/getexecname.c @@ -41,7 +41,8 @@ getexecname(void) pthread_mutex_lock(&mtx); if (strlen(execname) == 0) { - rc = readlink("/proc/self/exe", execname, sizeof(execname) - 1); + rc = readlink("/proc/self/exe", + execname, sizeof (execname) - 1); if (rc == -1) { execname[0] = '\0'; } else { @@ -53,5 +54,5 @@ getexecname(void) } pthread_mutex_unlock(&mtx); - return ptr; + return (ptr); } diff --git a/lib/libspl/gethrestime.c b/lib/libspl/gethrestime.c index be163f86c..d37cc2d59 100644 --- a/lib/libspl/gethrestime.c +++ b/lib/libspl/gethrestime.c @@ -30,9 +30,9 @@ void gethrestime(timestruc_t *ts) { - struct timeval tv; + struct timeval tv; - gettimeofday(&tv, NULL); - ts->tv_sec = tv.tv_sec; - ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC; + gettimeofday(&tv, NULL); + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC; } diff --git a/lib/libspl/gethrtime.c b/lib/libspl/gethrtime.c index c2fd5e034..95ceb18e1 100644 --- a/lib/libspl/gethrtime.c +++ b/lib/libspl/gethrtime.c @@ -38,8 +38,8 @@ gethrtime(void) rc = clock_gettime(CLOCK_MONOTONIC, &ts); if (rc) { fprintf(stderr, "Error: clock_gettime() = %d\n", rc); - abort(); + abort(); } - return (((u_int64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec; + return ((((u_int64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec); } diff --git a/lib/libspl/getmntany.c b/lib/libspl/getmntany.c index f0b1cda4b..d78357af5 100644 --- a/lib/libspl/getmntany.c +++ b/lib/libspl/getmntany.c @@ -37,23 +37,25 @@ #include <sys/stat.h> #include <unistd.h> -#define BUFSIZE (MNT_LINE_MAX + 2) +#define BUFSIZE (MNT_LINE_MAX + 2) __thread char buf[BUFSIZE]; -#define DIFF(xx) ((mrefp->xx != NULL) && \ - (mgetp->xx == NULL || strcmp(mrefp->xx, mgetp->xx) != 0)) +#define DIFF(xx) ( \ + (mrefp->xx != NULL) && \ + (mgetp->xx == NULL || strcmp(mrefp->xx, mgetp->xx) != 0)) int getmntany(FILE *fp, struct mnttab *mgetp, struct mnttab *mrefp) { int ret; - while (((ret = _sol_getmntent(fp, mgetp)) == 0) && - (DIFF(mnt_special) || DIFF(mnt_mountp) || - DIFF(mnt_fstype) || DIFF(mnt_mntopts))); + while ( + ((ret = _sol_getmntent(fp, mgetp)) == 0) && ( + DIFF(mnt_special) || DIFF(mnt_mountp) || + DIFF(mnt_fstype) || DIFF(mnt_mntopts))); - return ret; + return (ret); } int @@ -69,13 +71,13 @@ _sol_getmntent(FILE *fp, struct mnttab *mgetp) mgetp->mnt_mountp = mntbuf.mnt_dir; mgetp->mnt_fstype = mntbuf.mnt_type; mgetp->mnt_mntopts = mntbuf.mnt_opts; - return 0; + return (0); } if (feof(fp)) - return -1; + return (-1); - return MNT_TOOLONG; + return (MNT_TOOLONG); } int @@ -89,11 +91,11 @@ getextmntent(FILE *fp, struct extmnttab *mp, int len) if (stat64(mp->mnt_mountp, &st) != 0) { mp->mnt_major = 0; mp->mnt_minor = 0; - return ret; + return (ret); } mp->mnt_major = major(st.st_dev); mp->mnt_minor = minor(st.st_dev); } - return ret; + return (ret); } diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h index 370416540..d749d1e9c 100644 --- a/lib/libspl/include/assert.h +++ b/lib/libspl/include/assert.h @@ -27,7 +27,7 @@ #include_next <assert.h> #ifndef _LIBSPL_ASSERT_H -#define _LIBSPL_ASSERT_H +#define _LIBSPL_ASSERT_H #include <stdio.h> #include <stdlib.h> diff --git a/lib/libspl/include/devid.h b/lib/libspl/include/devid.h index 9dfdae84b..5406c33b5 100644 --- a/lib/libspl/include/devid.h +++ b/lib/libspl/include/devid.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_DEVID_H -#define _LIBSPL_DEVID_H +#define _LIBSPL_DEVID_H #include <stdlib.h> @@ -36,13 +36,73 @@ typedef struct devid_nmlist { dev_t dev; } devid_nmlist_t; -static inline int devid_str_decode(char *devidstr, ddi_devid_t *retdevid, char **retminor_name) { abort(); } -static inline int devid_deviceid_to_nmlist(char *search_path, ddi_devid_t devid, char *minor_name, devid_nmlist_t **retlist) { abort(); } -static inline void devid_str_free(char *str) { abort(); } -static inline void devid_free(ddi_devid_t devid) { abort(); } -static inline void devid_free_nmlist(devid_nmlist_t *list) { abort(); } -static inline int devid_get(int fd, ddi_devid_t *retdevid) { return -1; } -static inline int devid_get_minor_name(int fd, char **retminor_name) { abort(); } -static inline char *devid_str_encode(ddi_devid_t devid, char *minor_name) { abort(); } +static inline +int +devid_str_decode( + char *devidstr, + ddi_devid_t *retdevid, + char **retminor_name) +{ + abort(); +} + +static inline +int +devid_deviceid_to_nmlist( + char *search_path, + ddi_devid_t devid, + char *minor_name, + devid_nmlist_t **retlist) +{ + abort(); +} + +static inline +void +devid_str_free(char *str) +{ + abort(); +} + +static inline +void +devid_free(ddi_devid_t devid) +{ + abort(); +} + +static inline +void +devid_free_nmlist(devid_nmlist_t *list) +{ + abort(); +} + +static inline +int +devid_get( + int fd, + ddi_devid_t *retdevid) +{ + return (-1); +} + +static inline +int +devid_get_minor_name( + int fd, + char **retminor_name) +{ + abort(); +} + +static inline +char * +devid_str_encode( + ddi_devid_t devid, + char *minor_name) +{ + abort(); +} #endif diff --git a/lib/libspl/include/libdevinfo.h b/lib/libspl/include/libdevinfo.h index f0f9d7e8e..be1d291f4 100644 --- a/lib/libspl/include/libdevinfo.h +++ b/lib/libspl/include/libdevinfo.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_LIBDEVINFO_H -#define _LIBSPL_LIBDEVINFO_H +#define _LIBSPL_LIBDEVINFO_H #endif /* _LIBSPL_LIBDEVINFO_H */ diff --git a/lib/libspl/include/libgen.h b/lib/libspl/include/libgen.h index 29e5400d4..7c03d81fd 100644 --- a/lib/libspl/include/libgen.h +++ b/lib/libspl/include/libgen.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_LIBGEN_H -#define _LIBSPL_LIBGEN_H +#define _LIBSPL_LIBGEN_H #include <sys/types.h> diff --git a/lib/libspl/include/libshare.h b/lib/libspl/include/libshare.h index a35bfacd7..4016ff031 100644 --- a/lib/libspl/include/libshare.h +++ b/lib/libspl/include/libshare.h @@ -24,7 +24,7 @@ * Use is subject to license terms. */ #ifndef _LIBSPL_LIBSHARE_H -#define _LIBSPL_LIBSHARE_H +#define _LIBSPL_LIBSHARE_H typedef void *sa_handle_t; /* opaque handle to access core functions */ typedef void *sa_group_t; diff --git a/lib/libspl/include/limits.h b/lib/libspl/include/limits.h index 341a2eba9..1a42cfec4 100644 --- a/lib/libspl/include/limits.h +++ b/lib/libspl/include/limits.h @@ -27,14 +27,14 @@ #include_next <limits.h> #ifndef _LIBSPL_LIMITS_H -#define _LIBSPL_LIMITS_H +#define _LIBSPL_LIMITS_H -#define DBL_DIG 15 -#define DBL_MAX 1.7976931348623157081452E+308 -#define DBL_MIN 2.2250738585072013830903E-308 +#define DBL_DIG 15 +#define DBL_MAX 1.7976931348623157081452E+308 +#define DBL_MIN 2.2250738585072013830903E-308 -#define FLT_DIG 6 -#define FLT_MAX 3.4028234663852885981170E+38F -#define FLT_MIN 1.1754943508222875079688E-38F +#define FLT_DIG 6 +#define FLT_MAX 3.4028234663852885981170E+38F +#define FLT_MIN 1.1754943508222875079688E-38F #endif /* _LIBSPL_LIMITS_H */ diff --git a/lib/libspl/include/locale.h b/lib/libspl/include/locale.h index 98ca330c3..6c74df720 100644 --- a/lib/libspl/include/locale.h +++ b/lib/libspl/include/locale.h @@ -27,7 +27,7 @@ #include_next <locale.h> #ifndef _LIBSPL_LOCALE_H -#define _LIBSPL_LOCALE_H +#define _LIBSPL_LOCALE_H #include <time.h> #include <sys/time.h> diff --git a/lib/libspl/include/note.h b/lib/libspl/include/note.h index ed6b4ba1c..cb6b33e1d 100644 --- a/lib/libspl/include/note.h +++ b/lib/libspl/include/note.h @@ -36,7 +36,7 @@ */ #ifndef _NOTE_H -#define _NOTE_H +#define _NOTE_H #include <sys/note.h> @@ -44,7 +44,7 @@ extern "C" { #endif -#define NOTE _NOTE +#define NOTE _NOTE #ifdef __cplusplus } diff --git a/lib/libspl/include/priv.h b/lib/libspl/include/priv.h index 3e8b138a0..15b76a400 100644 --- a/lib/libspl/include/priv.h +++ b/lib/libspl/include/priv.h @@ -25,12 +25,12 @@ */ #ifndef _LIBSPL_PRIV_H -#define _LIBSPL_PRIV_H +#define _LIBSPL_PRIV_H #include <sys/types.h> /* Couldn't find this definition in OpenGrok */ -#define PRIV_SYS_CONFIG "sys_config" +#define PRIV_SYS_CONFIG "sys_config" /* * priv_op_t indicates a privilege operation type diff --git a/lib/libspl/include/rpc/types.h b/lib/libspl/include/rpc/types.h index 68c17f103..aa9901fd1 100644 --- a/lib/libspl/include/rpc/types.h +++ b/lib/libspl/include/rpc/types.h @@ -24,7 +24,7 @@ */ #ifndef LIBSPL_RPC_TYPES_H -#define LIBSPL_RPC_TYPES_H +#define LIBSPL_RPC_TYPES_H #include_next <rpc/types.h> #include <sys/kmem.h> diff --git a/lib/libspl/include/rpc/xdr.h b/lib/libspl/include/rpc/xdr.h index cd6680f57..99500d657 100644 --- a/lib/libspl/include/rpc/xdr.h +++ b/lib/libspl/include/rpc/xdr.h @@ -30,7 +30,7 @@ */ #ifndef LIBSPL_RPC_XDR_H -#define LIBSPL_RPC_XDR_H +#define LIBSPL_RPC_XDR_H #include_next <rpc/xdr.h> @@ -55,10 +55,10 @@ typedef struct xdr_bytesrec { * XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in * the XDR stream moving over RDMA. */ -#define XDR_PEEK 2 -#define XDR_SKIPBYTES 3 -#define XDR_RDMAGET 4 -#define XDR_RDMASET 5 +#define XDR_PEEK 2 +#define XDR_SKIPBYTES 3 +#define XDR_RDMAGET 4 +#define XDR_RDMASET 5 extern bool_t xdr_control(XDR *xdrs, int request, void *info); diff --git a/lib/libspl/include/stdio.h b/lib/libspl/include/stdio.h index f80fdc009..6152b09f1 100644 --- a/lib/libspl/include/stdio.h +++ b/lib/libspl/include/stdio.h @@ -27,8 +27,8 @@ #include_next <stdio.h> #ifndef _LIBSPL_STDIO_H -#define _LIBSPL_STDIO_H +#define _LIBSPL_STDIO_H -#define enable_extended_FILE_stdio(fd, sig) ((void) 0) +#define enable_extended_FILE_stdio(fd, sig) ((void) 0) #endif diff --git a/lib/libspl/include/stdlib.h b/lib/libspl/include/stdlib.h index 67d6e96e0..a4ce4f781 100644 --- a/lib/libspl/include/stdlib.h +++ b/lib/libspl/include/stdlib.h @@ -27,7 +27,7 @@ #include_next <stdlib.h> #ifndef _LIBSPL_STDLIB_H -#define _LIBSPL_STDLIB_H +#define _LIBSPL_STDLIB_H extern const char *getexecname(void); diff --git a/lib/libspl/include/string.h b/lib/libspl/include/string.h index 213977d0e..9e5133e0e 100644 --- a/lib/libspl/include/string.h +++ b/lib/libspl/include/string.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_STRING_H -#define _LIBSPL_STRING_H +#define _LIBSPL_STRING_H #include_next <string.h> diff --git a/lib/libspl/include/strings.h b/lib/libspl/include/strings.h index 48944e142..3f35af4a4 100644 --- a/lib/libspl/include/strings.h +++ b/lib/libspl/include/strings.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_STRINGS_H -#define _LIBSPL_STRINGS_H +#define _LIBSPL_STRINGS_H #include <string.h> #include_next <strings.h> diff --git a/lib/libspl/include/synch.h b/lib/libspl/include/synch.h index 2da270a42..7ce2a53d4 100644 --- a/lib/libspl/include/synch.h +++ b/lib/libspl/include/synch.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYNCH_H -#define _LIBSPL_SYNCH_H +#define _LIBSPL_SYNCH_H #endif diff --git a/lib/libspl/include/sys/bitmap.h b/lib/libspl/include/sys/bitmap.h index 8fef7fcfe..95122ab8b 100644 --- a/lib/libspl/include/sys/bitmap.h +++ b/lib/libspl/include/sys/bitmap.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_BITMAP_H -#define _LIBSPL_SYS_BITMAP_H +#define _LIBSPL_SYS_BITMAP_H #endif diff --git a/lib/libspl/include/sys/callb.h b/lib/libspl/include/sys/callb.h index 29a6a6777..8ffd18788 100644 --- a/lib/libspl/include/sys/callb.h +++ b/lib/libspl/include/sys/callb.h @@ -25,6 +25,6 @@ */ #ifndef _SYS_CALLB_H -#define _SYS_CALLB_H +#define _SYS_CALLB_H #endif diff --git a/lib/libspl/include/sys/cmn_err.h b/lib/libspl/include/sys/cmn_err.h index d199361d7..63ff4eb29 100644 --- a/lib/libspl/include/sys/cmn_err.h +++ b/lib/libspl/include/sys/cmn_err.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_CMN_ERR_H -#define _LIBSPL_SYS_CMN_ERR_H +#define _LIBSPL_SYS_CMN_ERR_H #endif diff --git a/lib/libspl/include/sys/compress.h b/lib/libspl/include/sys/compress.h index 6e03e73a3..282f178ba 100644 --- a/lib/libspl/include/sys/compress.h +++ b/lib/libspl/include/sys/compress.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_COMPRESS_H -#define _LIBSPL_SYS_COMPRESS_H +#define _LIBSPL_SYS_COMPRESS_H #endif /* _LIBSPL_SYS_COMPRESS_H */ diff --git a/lib/libspl/include/sys/cred.h b/lib/libspl/include/sys/cred.h index 6a58315d4..463b3abfc 100644 --- a/lib/libspl/include/sys/cred.h +++ b/lib/libspl/include/sys/cred.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_SYS_CRED_H -#define _LIBSPL_SYS_CRED_H +#define _LIBSPL_SYS_CRED_H typedef struct cred cred_t; diff --git a/lib/libspl/include/sys/debug.h b/lib/libspl/include/sys/debug.h index 006962055..fde4a0120 100644 --- a/lib/libspl/include/sys/debug.h +++ b/lib/libspl/include/sys/debug.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_SYS_DEBUG_H -#define _LIBSPL_SYS_DEBUG_H +#define _LIBSPL_SYS_DEBUG_H #include <assert.h> diff --git a/lib/libspl/include/sys/feature_tests.h b/lib/libspl/include/sys/feature_tests.h index 96f627172..1a68b75f0 100644 --- a/lib/libspl/include/sys/feature_tests.h +++ b/lib/libspl/include/sys/feature_tests.h @@ -25,8 +25,8 @@ */ #ifndef _SYS_FEATURE_TESTS_H -#define _SYS_FEATURE_TESTS_H +#define _SYS_FEATURE_TESTS_H -#define __NORETURN __attribute__((__noreturn__)) +#define __NORETURN __attribute__((__noreturn__)) #endif diff --git a/lib/libspl/include/sys/file.h b/lib/libspl/include/sys/file.h index 9aaba35be..163a4dca6 100644 --- a/lib/libspl/include/sys/file.h +++ b/lib/libspl/include/sys/file.h @@ -25,26 +25,26 @@ */ #ifndef _LIBSPL_SYS_FILE_H -#define _LIBSPL_SYS_FILE_H +#define _LIBSPL_SYS_FILE_H #include_next <sys/file.h> #include <sys/user.h> -#define FREAD 1 -#define FWRITE 2 -//#define FAPPEND 8 +#define FREAD 1 +#define FWRITE 2 +// #define FAPPEND 8 -#define FCREAT O_CREAT -#define FTRUNC O_TRUNC -#define FOFFMAX O_LARGEFILE -#define FSYNC O_SYNC -#define FDSYNC O_DSYNC -#define FRSYNC O_RSYNC -#define FEXCL O_EXCL +#define FCREAT O_CREAT +#define FTRUNC O_TRUNC +#define FOFFMAX O_LARGEFILE +#define FSYNC O_SYNC +#define FDSYNC O_DSYNC +#define FRSYNC O_RSYNC +#define FEXCL O_EXCL -#define FNODSYNC 0x10000 /* fsync pseudo flag */ -#define FNOFOLLOW 0x20000 /* don't follow symlinks */ -#define FIGNORECASE 0x80000 /* request case-insensitive lookups */ +#define FNODSYNC 0x10000 /* fsync pseudo flag */ +#define FNOFOLLOW 0x20000 /* don't follow symlinks */ +#define FIGNORECASE 0x80000 /* request case-insensitive lookups */ #endif diff --git a/lib/libspl/include/sys/frame.h b/lib/libspl/include/sys/frame.h index f936ab825..a4c7d8bb5 100644 --- a/lib/libspl/include/sys/frame.h +++ b/lib/libspl/include/sys/frame.h @@ -25,7 +25,7 @@ */ #ifndef _SYS_FRAME_H -#define _SYS_FRAME_H +#define _SYS_FRAME_H #include <sys/types.h> diff --git a/lib/libspl/include/sys/int_limits.h b/lib/libspl/include/sys/int_limits.h index 2b50ddd1b..7af68cdb2 100644 --- a/lib/libspl/include/sys/int_limits.h +++ b/lib/libspl/include/sys/int_limits.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_INT_LIMITS_H -#define _LIBSPL_SYS_INT_LIMITS_H +#define _LIBSPL_SYS_INT_LIMITS_H #endif diff --git a/lib/libspl/include/sys/int_types.h b/lib/libspl/include/sys/int_types.h index b32512282..51e9e0285 100644 --- a/lib/libspl/include/sys/int_types.h +++ b/lib/libspl/include/sys/int_types.h @@ -25,7 +25,7 @@ */ #ifndef _SOL_SYS_INT_TYPES_H -#define _SOL_SYS_INT_TYPES_H +#define _SOL_SYS_INT_TYPES_H #include <inttypes.h> diff --git a/lib/libspl/include/sys/inttypes.h b/lib/libspl/include/sys/inttypes.h index 7630f2d4c..d7d063985 100644 --- a/lib/libspl/include/sys/inttypes.h +++ b/lib/libspl/include/sys/inttypes.h @@ -25,10 +25,10 @@ */ #ifndef _SOL_SYS_INTTYPES_H -#define _SOL_SYS_INTTYPES_H +#define _SOL_SYS_INTTYPES_H #include <inttypes.h> -#define _INT64_TYPE +#define _INT64_TYPE #endif diff --git a/lib/libspl/include/sys/isa_defs.h b/lib/libspl/include/sys/isa_defs.h index 4ab07eb2b..7c5df7737 100644 --- a/lib/libspl/include/sys/isa_defs.h +++ b/lib/libspl/include/sys/isa_defs.h @@ -35,91 +35,91 @@ extern "C" { #if defined(__x86_64) || defined(__x86_64__) #if !defined(__x86_64) -#define __x86_64 +#define __x86_64 #endif #if !defined(__amd64) -#define __amd64 +#define __amd64 #endif #if !defined(__x86) -#define __x86 +#define __x86 #endif #if !defined(_LP64) -#define _LP64 +#define _LP64 #endif #if !defined(_LITTLE_ENDIAN) -#define _LITTLE_ENDIAN +#define _LITTLE_ENDIAN #endif -#define _SUNOS_VTOC_16 +#define _SUNOS_VTOC_16 /* i386 arch specific defines */ #elif defined(__i386) || defined(__i386__) #if !defined(__i386) -#define __i386 +#define __i386 #endif #if !defined(__x86) -#define __x86 +#define __x86 #endif #if !defined(_ILP32) -#define _ILP32 +#define _ILP32 #endif #if !defined(_LITTLE_ENDIAN) -#define _LITTLE_ENDIAN +#define _LITTLE_ENDIAN #endif -#define _SUNOS_VTOC_16 +#define _SUNOS_VTOC_16 /* powerpc arch specific defines */ #elif defined(__powerpc) || defined(__powerpc__) #if !defined(__powerpc) -#define __powerpc +#define __powerpc #endif #if !defined(__powerpc__) -#define __powerpc__ +#define __powerpc__ #endif #if !defined(_LP64) #ifdef __powerpc64__ -#define _LP64 +#define _LP64 #else -#define _LP32 +#define _LP32 #endif #endif #if !defined(_BIG_ENDIAN) -#define _BIG_ENDIAN +#define _BIG_ENDIAN #endif -#define _SUNOS_VTOC_16 +#define _SUNOS_VTOC_16 /* arm arch specific defines */ #elif defined(__arm) || defined(__arm__) #if !defined(__arm) -#define __arm +#define __arm #endif #if !defined(__arm__) -#define __arm__ +#define __arm__ #endif #if defined(__ARMEL__) -#define _LITTLE_ENDIAN +#define _LITTLE_ENDIAN #else -#define _BIG_ENDIAN +#define _BIG_ENDIAN #endif -#define _SUNOS_VTOC_16 +#define _SUNOS_VTOC_16 #else /* Currently only x86_64, i386, arm, and powerpc arches supported */ #error "Unsupported ISA type" diff --git a/lib/libspl/include/sys/kmem.h b/lib/libspl/include/sys/kmem.h index 401e04072..83d47565a 100644 --- a/lib/libspl/include/sys/kmem.h +++ b/lib/libspl/include/sys/kmem.h @@ -35,8 +35,8 @@ extern "C" { #define KM_SLEEP 0x00000000 /* same as KM_SLEEP */ #define KM_NOSLEEP 0x00000001 /* same as KM_NOSLEEP */ -#define kmem_alloc(size, flags) malloc(size) -#define kmem_free(ptr, size) free(ptr) +#define kmem_alloc(size, flags) malloc(size) +#define kmem_free(ptr, size) free(ptr) #ifdef __cplusplus } diff --git a/lib/libspl/include/sys/mkdev.h b/lib/libspl/include/sys/mkdev.h index 76e3a4fff..5978de65d 100644 --- a/lib/libspl/include/sys/mkdev.h +++ b/lib/libspl/include/sys/mkdev.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_MKDEV_H -#define _LIBSPL_SYS_MKDEV_H +#define _LIBSPL_SYS_MKDEV_H #endif diff --git a/lib/libspl/include/sys/mnttab.h b/lib/libspl/include/sys/mnttab.h index a30549a72..6bfbdd69c 100644 --- a/lib/libspl/include/sys/mnttab.h +++ b/lib/libspl/include/sys/mnttab.h @@ -19,7 +19,7 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T*/ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. @@ -28,7 +28,7 @@ /* Copyright 2006 Ricardo Correia */ #ifndef _SYS_MNTTAB_H -#define _SYS_MNTTAB_H +#define _SYS_MNTTAB_H #include <stdio.h> #include <mntent.h> @@ -77,10 +77,10 @@ static inline char *_sol_hasmntopt(struct mnttab *mnt, char *opt) mnt_new.mnt_opts = mnt->mnt_mntopts; - return hasmntopt(&mnt_new, opt); + return (hasmntopt(&mnt_new, opt)); } -#define hasmntopt _sol_hasmntopt -#define getmntent _sol_getmntent +#define hasmntopt _sol_hasmntopt +#define getmntent _sol_getmntent #endif diff --git a/lib/libspl/include/sys/mount.h b/lib/libspl/include/sys/mount.h index 0fa4f2554..41cd839b7 100644 --- a/lib/libspl/include/sys/mount.h +++ b/lib/libspl/include/sys/mount.h @@ -27,7 +27,7 @@ #include_next <sys/mount.h> #ifndef _LIBSPL_SYS_MOUNT_H -#define _LIBSPL_SYS_MOUNT_H +#define _LIBSPL_SYS_MOUNT_H #include <sys/mntent.h> #include <assert.h> @@ -39,7 +39,7 @@ * and we don't want to require the kernel headers */ #if !defined(BLKGETSIZE64) -#define BLKGETSIZE64 _IOR(0x12, 114, size_t) +#define BLKGETSIZE64 _IOR(0x12, 114, size_t) #endif /* @@ -48,7 +48,7 @@ * headers define MS_DIRSYNC to be S_WRITE. */ #if !defined(MS_DIRSYNC) -#define MS_DIRSYNC S_WRITE +#define MS_DIRSYNC S_WRITE #endif /* @@ -71,15 +71,15 @@ * kernel back to 2.4.11 so we define them correctly if they are missing. */ #ifdef MNT_FORCE -# define MS_FORCE MNT_FORCE +#define MS_FORCE MNT_FORCE #else -# define MS_FORCE 0x00000001 +#define MS_FORCE 0x00000001 #endif /* MNT_FORCE */ #ifdef MNT_DETACH -# define MS_DETACH MNT_DETACH +#define MS_DETACH MNT_DETACH #else -# define MS_DETACH 0x00000002 +#define MS_DETACH 0x00000002 #endif /* MNT_DETACH */ /* @@ -87,6 +87,6 @@ * compatibility, MS_OVERLAY is defined to explicitly have the user * provide a flag (-O) to mount over a non empty directory. */ -#define MS_OVERLAY 0x00000004 +#define MS_OVERLAY 0x00000004 #endif /* _LIBSPL_SYS_MOUNT_H */ diff --git a/lib/libspl/include/sys/param.h b/lib/libspl/include/sys/param.h index 75cf0b757..4090cefe8 100644 --- a/lib/libspl/include/sys/param.h +++ b/lib/libspl/include/sys/param.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_SYS_PARAM_H -#define _LIBSPL_SYS_PARAM_H +#define _LIBSPL_SYS_PARAM_H #include_next <sys/param.h> #include <unistd.h> @@ -43,20 +43,20 @@ * Note that the blocked devices are assumed to have DEV_BSIZE * "sectors" and that fragments must be some multiple of this size. */ -#define MAXBSIZE 8192 -#define DEV_BSIZE 512 -#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define MAXBSIZE 8192 +#define DEV_BSIZE 512 +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ -#define MAXNAMELEN 256 -#define MAXOFFSET_T LLONG_MAX +#define MAXNAMELEN 256 +#define MAXOFFSET_T LLONG_MAX -#define UID_NOBODY 60001 /* user ID no body */ -#define GID_NOBODY UID_NOBODY -#define UID_NOACCESS 60002 /* user ID no access */ +#define UID_NOBODY 60001 /* user ID no body */ +#define GID_NOBODY UID_NOBODY +#define UID_NOACCESS 60002 /* user ID no access */ -#define MAXUID UINT32_MAX /* max user id */ -#define MAXPROJID MAXUID /* max project id */ +#define MAXUID UINT32_MAX /* max user id */ +#define MAXPROJID MAXUID /* max project id */ -#define PAGESIZE (sysconf(_SC_PAGESIZE)) +#define PAGESIZE (sysconf(_SC_PAGESIZE)) #endif diff --git a/lib/libspl/include/sys/priv.h b/lib/libspl/include/sys/priv.h index 4a3ab9684..76c76d183 100644 --- a/lib/libspl/include/sys/priv.h +++ b/lib/libspl/include/sys/priv.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_PRIV_H -#define _LIBSPL_SYS_PRIV_H +#define _LIBSPL_SYS_PRIV_H #endif diff --git a/lib/libspl/include/sys/processor.h b/lib/libspl/include/sys/processor.h index 0af9dc06b..78e95d01f 100644 --- a/lib/libspl/include/sys/processor.h +++ b/lib/libspl/include/sys/processor.h @@ -25,9 +25,9 @@ */ #ifndef _LIBSPL_SYS_PROCESSOR_H -#define _LIBSPL_SYS_PROCESSOR_H +#define _LIBSPL_SYS_PROCESSOR_H -#define getcpuid() (-1) +#define getcpuid() (-1) typedef int processorid_t; diff --git a/lib/libspl/include/sys/sdt.h b/lib/libspl/include/sys/sdt.h index 79733eef0..f68f79040 100644 --- a/lib/libspl/include/sys/sdt.h +++ b/lib/libspl/include/sys/sdt.h @@ -25,12 +25,12 @@ */ #ifndef _LIBSPL_SYS_SDT_H -#define _LIBSPL_SYS_SDT_H +#define _LIBSPL_SYS_SDT_H -#define DTRACE_PROBE(a) ((void) 0) -#define DTRACE_PROBE1(a,b,c) ((void) 0) -#define DTRACE_PROBE2(a,b,c,d,e) ((void) 0) -#define DTRACE_PROBE3(a,b,c,d,e,f,g) ((void) 0) -#define DTRACE_PROBE4(a,b,c,d,e,f,g,h,i) ((void) 0) +#define DTRACE_PROBE(a) ((void) 0) +#define DTRACE_PROBE1(a, b, c) ((void) 0) +#define DTRACE_PROBE2(a, b, c, d, e) ((void) 0) +#define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void) 0) +#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void) 0) #endif diff --git a/lib/libspl/include/sys/stack.h b/lib/libspl/include/sys/stack.h index 41f0beb16..59807e97b 100644 --- a/lib/libspl/include/sys/stack.h +++ b/lib/libspl/include/sys/stack.h @@ -23,11 +23,11 @@ * Portions Copyright 2008 Sun Microsystems, Inc. All Rights reserved. */ #ifndef _SYS_STACK_H -#define _SYS_STACK_H +#define _SYS_STACK_H #include <pthread.h> -#define STACK_BIAS 0 +#define STACK_BIAS 0 #ifdef __USE_GNU @@ -39,7 +39,7 @@ stack_getbounds(stack_t *sp) rc = pthread_getattr_np(pthread_self(), &attr); if (rc) - return rc; + return (rc); rc = pthread_attr_getstack(&attr, &sp->ss_sp, &sp->ss_size); if (rc == 0) @@ -47,7 +47,7 @@ stack_getbounds(stack_t *sp) pthread_attr_destroy(&attr); - return rc; + return (rc); } static inline int @@ -57,15 +57,17 @@ thr_stksegment(stack_t *sp) rc = stack_getbounds(sp); if (rc) - return rc; + return (rc); - /* thr_stksegment() is expected to set sp.ss_sp to the high stack - * address, but the stack_getbounds() interface is expected to - * set sp.ss_sp to the low address. Adjust accordingly. */ + /* + * thr_stksegment() is expected to set sp.ss_sp to the high stack + * address, but the stack_getbounds() interface is expected to + * set sp.ss_sp to the low address. Adjust accordingly. + */ sp->ss_sp = (void *)(((uintptr_t)sp->ss_sp) + sp->ss_size); sp->ss_flags = 0; - return rc; + return (rc); } #endif /* __USE_GNU */ diff --git a/lib/libspl/include/sys/stat.h b/lib/libspl/include/sys/stat.h index b9ad152bc..3e8d27e4c 100644 --- a/lib/libspl/include/sys/stat.h +++ b/lib/libspl/include/sys/stat.h @@ -24,7 +24,7 @@ */ #ifndef _LIBSPL_SYS_STAT_H -#define _LIBSPL_SYS_STAT_H +#define _LIBSPL_SYS_STAT_H #include_next <sys/stat.h> @@ -37,14 +37,14 @@ static inline int fstat64_blk(int fd, struct stat64 *st) { if (fstat64(fd, st) == -1) - return -1; + return (-1); /* In Linux we need to use an ioctl to get the size of a block device */ if (S_ISBLK(st->st_mode)) { if (ioctl(fd, BLKGETSIZE64, &st->st_size) != 0) - return -1; + return (-1); } - return 0; + return (0); } #endif /* _LIBSPL_SYS_STAT_H */ diff --git a/lib/libspl/include/sys/stropts.h b/lib/libspl/include/sys/stropts.h index e036b0ea2..08c2e79bc 100644 --- a/lib/libspl/include/sys/stropts.h +++ b/lib/libspl/include/sys/stropts.h @@ -24,6 +24,6 @@ */ #ifndef _LIBSPL_SYS_STROPTS_H -#define _LIBSPL_SYS_STROPTS_H +#define _LIBSPL_SYS_STROPTS_H #endif /* _LIBSPL_SYS_STROPTS_H */ diff --git a/lib/libspl/include/sys/sysevent.h b/lib/libspl/include/sys/sysevent.h index 980d14541..074d8419c 100644 --- a/lib/libspl/include/sys/sysevent.h +++ b/lib/libspl/include/sys/sysevent.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_SYSEVENT_H -#define _LIBSPL_SYS_SYSEVENT_H +#define _LIBSPL_SYS_SYSEVENT_H #endif diff --git a/lib/libspl/include/sys/sysmacros.h b/lib/libspl/include/sys/sysmacros.h index 07ab8c934..698b0a7a3 100644 --- a/lib/libspl/include/sys/sysmacros.h +++ b/lib/libspl/include/sys/sysmacros.h @@ -25,41 +25,41 @@ */ #ifndef _LIBSPL_SYS_SYSMACROS_H -#define _LIBSPL_SYS_SYSMACROS_H +#define _LIBSPL_SYS_SYSMACROS_H #include_next <sys/sysmacros.h> /* common macros */ #ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif #ifndef MAX -#define MAX(a, b) ((a) < (b) ? (b) : (a)) +#define MAX(a, b) ((a) < (b) ? (b) : (a)) #endif #ifndef ABS -#define ABS(a) ((a) < 0 ? -(a) : (a)) +#define ABS(a) ((a) < 0 ? -(a) : (a)) #endif -#define makedevice(maj,min) makedev(maj,min) -#define _sysconf(a) sysconf(a) -#define __NORETURN __attribute__ ((noreturn)) +#define makedevice(maj, min) makedev(maj, min) +#define _sysconf(a) sysconf(a) +#define __NORETURN __attribute__((noreturn)) /* * Compatibility macros/typedefs needed for Solaris -> Linux port */ -#define P2ALIGN(x, align) ((x) & -(align)) -#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1) -#define P2ROUNDUP(x, align) (-(-(x) & -(align))) -#define P2ROUNDUP_TYPED(x, align, type) \ +#define P2ALIGN(x, align) ((x) & -(align)) +#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1) +#define P2ROUNDUP(x, align) (-(-(x) & -(align))) +#define P2ROUNDUP_TYPED(x, align, type) \ (-(-(type)(x) & -(type)(align))) -#define P2BOUNDARY(off, len, align) \ +#define P2BOUNDARY(off, len, align) \ (((off) ^ ((off) + (len) - 1)) > (align) - 1) -#define P2PHASE(x, align) ((x) & ((align) - 1)) -#define P2NPHASE(x, align) (-(x) & ((align) - 1)) -#define P2NPHASE_TYPED(x, align, type) \ +#define P2PHASE(x, align) ((x) & ((align) - 1)) +#define P2NPHASE(x, align) (-(x) & ((align) - 1)) +#define P2NPHASE_TYPED(x, align, type) \ (-(type)(x) & ((type)(align) - 1)) -#define ISP2(x) (((x) & ((x) - 1)) == 0) -#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) +#define ISP2(x) (((x) & ((x) - 1)) == 0) +#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) /* * Typed version of the P2* macros. These macros should be used to ensure @@ -72,22 +72,22 @@ * or * P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t) */ -#define P2ALIGN_TYPED(x, align, type) \ - ((type)(x) & -(type)(align)) -#define P2PHASE_TYPED(x, align, type) \ - ((type)(x) & ((type)(align) - 1)) -#define P2NPHASE_TYPED(x, align, type) \ - (-(type)(x) & ((type)(align) - 1)) -#define P2ROUNDUP_TYPED(x, align, type) \ - (-(-(type)(x) & -(type)(align))) -#define P2END_TYPED(x, align, type) \ - (-(~(type)(x) & -(type)(align))) -#define P2PHASEUP_TYPED(x, align, phase, type) \ - ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align))) -#define P2CROSS_TYPED(x, y, align, type) \ - (((type)(x) ^ (type)(y)) > (type)(align) - 1) -#define P2SAMEHIGHBIT_TYPED(x, y, type) \ - (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y))) +#define P2ALIGN_TYPED(x, align, type) \ + ((type)(x) & -(type)(align)) +#define P2PHASE_TYPED(x, align, type) \ + ((type)(x) & ((type)(align) - 1)) +#define P2NPHASE_TYPED(x, align, type) \ + (-(type)(x) & ((type)(align) - 1)) +#define P2ROUNDUP_TYPED(x, align, type) \ + (-(-(type)(x) & -(type)(align))) +#define P2END_TYPED(x, align, type) \ + (-(~(type)(x) & -(type)(align))) +#define P2PHASEUP_TYPED(x, align, phase, type) \ + ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align))) +#define P2CROSS_TYPED(x, y, align, type) \ + (((type)(x) ^ (type)(y)) > (type)(align) - 1) +#define P2SAMEHIGHBIT_TYPED(x, y, type) \ + (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y))) /* avoid any possibility of clashing with <stddef.h> version */ diff --git a/lib/libspl/include/sys/systeminfo.h b/lib/libspl/include/sys/systeminfo.h index 9f561aaa8..3f7cef5b9 100644 --- a/lib/libspl/include/sys/systeminfo.h +++ b/lib/libspl/include/sys/systeminfo.h @@ -25,13 +25,13 @@ */ #ifndef _LIBSPL_SYS_SYSTEMINFO_H -#define _LIBSPL_SYS_SYSTEMINFO_H +#define _LIBSPL_SYS_SYSTEMINFO_H -#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */ -#define HW_HOSTID_LEN 11 /* minimum buffer size needed */ +#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */ +#define HW_HOSTID_LEN 11 /* minimum buffer size needed */ /* to hold a decimal or hex */ /* hostid string */ -#define sysinfo(cmd,buf,cnt) (-1) +#define sysinfo(cmd, buf, cnt) (-1) #endif diff --git a/lib/libspl/include/sys/systm.h b/lib/libspl/include/sys/systm.h index 5cb088dcc..1ed031d4e 100644 --- a/lib/libspl/include/sys/systm.h +++ b/lib/libspl/include/sys/systm.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_SYSTM_H -#define _LIBSPL_SYS_SYSTM_H +#define _LIBSPL_SYS_SYSTM_H #endif /* _LIBSPL_SYS_SYSTM_H */ diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h index 852b2eff9..f0da440a2 100644 --- a/lib/libspl/include/sys/time.h +++ b/lib/libspl/include/sys/time.h @@ -25,37 +25,37 @@ */ #ifndef _LIBSPL_SYS_TIME_H -#define _LIBSPL_SYS_TIME_H +#define _LIBSPL_SYS_TIME_H #include_next <sys/time.h> #include <sys/types.h> #ifndef SEC -#define SEC 1 +#define SEC 1 #endif #ifndef MILLISEC -#define MILLISEC 1000 +#define MILLISEC 1000 #endif #ifndef MICROSEC -#define MICROSEC 1000000 +#define MICROSEC 1000000 #endif #ifndef NANOSEC -#define NANOSEC 1000000000 +#define NANOSEC 1000000000 #endif #ifndef NSEC_PER_USEC -#define NSEC_PER_USEC 1000L +#define NSEC_PER_USEC 1000L #endif #ifndef MSEC2NSEC -#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC)) +#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC)) #endif #ifndef NSEC2MSEC -#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) +#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) #endif extern hrtime_t gethrtime(void); diff --git a/lib/libspl/include/sys/types.h b/lib/libspl/include/sys/types.h index 77a5b2359..bd34dec32 100644 --- a/lib/libspl/include/sys/types.h +++ b/lib/libspl/include/sys/types.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_SYS_TYPES_H -#define _LIBSPL_SYS_TYPES_H +#define _LIBSPL_SYS_TYPES_H #include <sys/isa_defs.h> #include <sys/feature_tests.h> @@ -53,9 +53,9 @@ typedef u_longlong_t u_offset_t; typedef u_longlong_t len_t; typedef longlong_t diskaddr_t; -typedef ulong_t pfn_t; /* page frame number */ -typedef ulong_t pgcnt_t; /* number of pages */ -typedef long spgcnt_t; /* signed number of pages */ +typedef ulong_t pfn_t; /* page frame number */ +typedef ulong_t pgcnt_t; /* number of pages */ +typedef long spgcnt_t; /* signed number of pages */ typedef longlong_t hrtime_t; typedef struct timespec timestruc_t; diff --git a/lib/libspl/include/sys/uio.h b/lib/libspl/include/sys/uio.h index 8adc923e5..97e8412ef 100644 --- a/lib/libspl/include/sys/uio.h +++ b/lib/libspl/include/sys/uio.h @@ -45,14 +45,14 @@ typedef struct iovec iovec_t; typedef enum uio_rw { - UIO_READ = 0, - UIO_WRITE = 1, + UIO_READ = 0, + UIO_WRITE = 1, } uio_rw_t; typedef enum uio_seg { - UIO_USERSPACE = 0, - UIO_SYSSPACE = 1, - UIO_USERISPACE= 2, + UIO_USERSPACE = 0, + UIO_SYSSPACE = 1, + UIO_USERISPACE = 2, } uio_seg_t; typedef struct uio { @@ -102,7 +102,7 @@ typedef struct xuio { } xu_ext; } xuio_t; -#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv -#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw +#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv +#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw #endif /* _SYS_UIO_H */ diff --git a/lib/libspl/include/sys/utsname.h b/lib/libspl/include/sys/utsname.h index fd323b96d..e16e22dbd 100644 --- a/lib/libspl/include/sys/utsname.h +++ b/lib/libspl/include/sys/utsname.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_UTSNAME_H -#define _LIBSPL_UTSNAME_H +#define _LIBSPL_UTSNAME_H #include_next <sys/utsname.h> diff --git a/lib/libspl/include/sys/va_list.h b/lib/libspl/include/sys/va_list.h index cf6045451..04ad1480e 100644 --- a/lib/libspl/include/sys/va_list.h +++ b/lib/libspl/include/sys/va_list.h @@ -25,7 +25,7 @@ */ #ifndef _SYS_VA_LIST_H -#define _SYS_VA_LIST_H +#define _SYS_VA_LIST_H #include <stdarg.h> diff --git a/lib/libspl/include/sys/varargs.h b/lib/libspl/include/sys/varargs.h index b8a63d8d7..3d00a3361 100644 --- a/lib/libspl/include/sys/varargs.h +++ b/lib/libspl/include/sys/varargs.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_VARARGS_H -#define _LIBSPL_SYS_VARARGS_H +#define _LIBSPL_SYS_VARARGS_H #endif diff --git a/lib/libspl/include/sys/vnode.h b/lib/libspl/include/sys/vnode.h index f25e9e9c4..efcdd2c5a 100644 --- a/lib/libspl/include/sys/vnode.h +++ b/lib/libspl/include/sys/vnode.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_VNODE_H -#define _LIBSPL_SYS_VNODE_H +#define _LIBSPL_SYS_VNODE_H #endif /* _LIBSPL_SYS_VNODE_H */ diff --git a/lib/libspl/include/sys/zone.h b/lib/libspl/include/sys/zone.h index ea7c8bde3..bbb964dce 100644 --- a/lib/libspl/include/sys/zone.h +++ b/lib/libspl/include/sys/zone.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_SYS_ZONE_H -#define _LIBSPL_SYS_ZONE_H +#define _LIBSPL_SYS_ZONE_H #endif diff --git a/lib/libspl/include/thread.h b/lib/libspl/include/thread.h index a72f6d2b1..74694e23e 100644 --- a/lib/libspl/include/thread.h +++ b/lib/libspl/include/thread.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_THREAD_H -#define _LIBSPL_THREAD_H +#define _LIBSPL_THREAD_H #endif /* _LIBSPL_THREAD_H */ diff --git a/lib/libspl/include/tzfile.h b/lib/libspl/include/tzfile.h index 441b8cf8b..7bd4087cd 100644 --- a/lib/libspl/include/tzfile.h +++ b/lib/libspl/include/tzfile.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_TZFILE_H -#define _LIBSPL_TZFILE_H +#define _LIBSPL_TZFILE_H #include <sys/tzfile.h> diff --git a/lib/libspl/include/ucred.h b/lib/libspl/include/ucred.h index 4ca424ed3..8178fdec4 100644 --- a/lib/libspl/include/ucred.h +++ b/lib/libspl/include/ucred.h @@ -25,7 +25,7 @@ */ #ifndef _LIBSPL_UCRED_H -#define _LIBSPL_UCRED_H +#define _LIBSPL_UCRED_H typedef int ucred_t; diff --git a/lib/libspl/include/umem.h b/lib/libspl/include/umem.h index f102f662a..68ff9a576 100644 --- a/lib/libspl/include/umem.h +++ b/lib/libspl/include/umem.h @@ -25,9 +25,10 @@ */ #ifndef _LIBSPL_UMEM_H -#define _LIBSPL_UMEM_H +#define _LIBSPL_UMEM_H -/* XXX: We should use the real portable umem library if it is detected +/* + * XXX: We should use the real portable umem library if it is detected * at configure time. However, if the library is not available, we can * use a trivial malloc based implementation. This obviously impacts * performance, but unless you are using a full userspace build of zpool for @@ -48,18 +49,18 @@ typedef void vmem_t; /* * Flags for umem_alloc/umem_free */ -#define UMEM_DEFAULT 0x0000 /* normal -- may fail */ -#define UMEM_NOFAIL 0x0100 /* Never fails */ +#define UMEM_DEFAULT 0x0000 /* normal -- may fail */ +#define UMEM_NOFAIL 0x0100 /* Never fails */ /* * Flags for umem_cache_create() */ -#define UMC_NOTOUCH 0x00010000 -#define UMC_NODEBUG 0x00020000 -#define UMC_NOMAGAZINE 0x00040000 -#define UMC_NOHASH 0x00080000 +#define UMC_NOTOUCH 0x00010000 +#define UMC_NODEBUG 0x00020000 +#define UMC_NOMAGAZINE 0x00040000 +#define UMC_NOHASH 0x00080000 -#define UMEM_CACHE_NAMELEN 31 +#define UMEM_CACHE_NAMELEN 31 typedef int umem_nofail_callback_t(void); typedef int umem_constructor_t(void *, void *, int); @@ -87,7 +88,7 @@ umem_alloc(size_t size, int flags) ptr = malloc(size); } while (ptr == NULL && (flags & UMEM_NOFAIL)); - return ptr; + return (ptr); } static inline void * @@ -105,10 +106,10 @@ umem_alloc_aligned(size_t size, size_t align, int flags) __func__, align); if (flags & UMEM_NOFAIL) abort(); - return NULL; + return (NULL); } - return ptr; + return (ptr); } static inline void * @@ -120,7 +121,7 @@ umem_zalloc(size_t size, int flags) if (ptr) memset(ptr, 0, size); - return ptr; + return (ptr); } static inline void @@ -133,15 +134,16 @@ static inline void umem_nofail_callback(umem_nofail_callback_t *cb) {} static inline umem_cache_t * -umem_cache_create(char *name, size_t bufsize, size_t align, - umem_constructor_t *constructor, - umem_destructor_t *destructor, - umem_reclaim_t *reclaim, - void *priv, void *vmp, int cflags) +umem_cache_create( + char *name, size_t bufsize, size_t align, + umem_constructor_t *constructor, + umem_destructor_t *destructor, + umem_reclaim_t *reclaim, + void *priv, void *vmp, int cflags) { umem_cache_t *cp; - cp = umem_alloc(sizeof(umem_cache_t), UMEM_DEFAULT); + cp = umem_alloc(sizeof (umem_cache_t), UMEM_DEFAULT); if (cp) { strncpy(cp->cache_name, name, UMEM_CACHE_NAMELEN); cp->cache_bufsize = bufsize; @@ -154,13 +156,13 @@ umem_cache_create(char *name, size_t bufsize, size_t align, cp->cache_cflags = cflags; } - return cp; + return (cp); } static inline void umem_cache_destroy(umem_cache_t *cp) { - umem_free(cp, sizeof(umem_cache_t)); + umem_free(cp, sizeof (umem_cache_t)); } static inline void * @@ -169,14 +171,15 @@ umem_cache_alloc(umem_cache_t *cp, int flags) void *ptr; if (cp->cache_align != 0) - ptr = umem_alloc_aligned(cp->cache_bufsize, cp->cache_align, flags); + ptr = umem_alloc_aligned( + cp->cache_bufsize, cp->cache_align, flags); else ptr = umem_alloc(cp->cache_bufsize, flags); if (ptr && cp->cache_constructor) cp->cache_constructor(ptr, cp->cache_private, UMEM_DEFAULT); - return ptr; + return (ptr); } static inline void diff --git a/lib/libspl/include/unistd.h b/lib/libspl/include/unistd.h index dc95e28b5..53851f4ab 100644 --- a/lib/libspl/include/unistd.h +++ b/lib/libspl/include/unistd.h @@ -27,21 +27,21 @@ #include_next <unistd.h> #ifndef _LIBSPL_UNISTD_H -#define _LIBSPL_UNISTD_H +#define _LIBSPL_UNISTD_H #if !defined(HAVE_IOCTL_IN_UNISTD_H) -# if defined(HAVE_IOCTL_IN_SYS_IOCTL_H) -# include <sys/ioctl.h> -# elif defined(HAVE_IOCTL_IN_STROPTS_H) -# include <stropts.h> -# else -# error "System call ioctl() unavailable" -# endif -#endif +#if defined(HAVE_IOCTL_IN_SYS_IOCTL_H) +#include <sys/ioctl.h> +#elif defined(HAVE_IOCTL_IN_STROPTS_H) +#include <stropts.h> +#else /* HAVE_IOCTL_IN_STROPTS_H */ +#error "System call ioctl() unavailable" +#endif /* HAVE_IOCTL_IN_SYS_IOCTL_H */ +#endif /* !HAVE_IOCTL_IN_UNISTD_H */ #if !defined(HAVE_ISSETUGID) -# include <sys/types.h> -# define issetugid() (geteuid() == 0 || getegid() == 0) +#include <sys/types.h> +#define issetugid() (geteuid() == 0 || getegid() == 0) #endif #endif /* _LIBSPL_UNISTD_H */ diff --git a/lib/libspl/include/util/sscanf.h b/lib/libspl/include/util/sscanf.h index 9d13bf25f..ead36acab 100644 --- a/lib/libspl/include/util/sscanf.h +++ b/lib/libspl/include/util/sscanf.h @@ -25,6 +25,6 @@ */ #ifndef _LIBSPL_UTIL_SSCANF_H -#define _LIBSPL_UTIL_SSCANF_H +#define _LIBSPL_UTIL_SSCANF_H #endif diff --git a/lib/libspl/include/zone.h b/lib/libspl/include/zone.h index dd24a1bb2..b4a6deb40 100644 --- a/lib/libspl/include/zone.h +++ b/lib/libspl/include/zone.h @@ -36,8 +36,8 @@ extern "C" { #endif -#define GLOBAL_ZONEID 0 -#define GLOBAL_ZONEID_NAME "global" +#define GLOBAL_ZONEID 0 +#define GLOBAL_ZONEID_NAME "global" /* * Functions for mapping between id and name for active zones. diff --git a/lib/libspl/zone.c b/lib/libspl/zone.c index f4269a76c..5ca93b224 100644 --- a/lib/libspl/zone.c +++ b/lib/libspl/zone.c @@ -27,34 +27,37 @@ #include <string.h> #include <errno.h> -zoneid_t getzoneid() +zoneid_t +getzoneid() { - return GLOBAL_ZONEID; + return (GLOBAL_ZONEID); } -zoneid_t getzoneidbyname(const char *name) +zoneid_t +getzoneidbyname(const char *name) { - if(name == NULL) - return GLOBAL_ZONEID; + if (name == NULL) + return (GLOBAL_ZONEID); - if(strcmp(name, GLOBAL_ZONEID_NAME) == 0) - return GLOBAL_ZONEID; + if (strcmp(name, GLOBAL_ZONEID_NAME) == 0) + return (GLOBAL_ZONEID); - return EINVAL; + return (EINVAL); } -ssize_t getzonenamebyid(zoneid_t id, char *buf, size_t buflen) +ssize_t +getzonenamebyid(zoneid_t id, char *buf, size_t buflen) { - if(id != GLOBAL_ZONEID) - return EINVAL; + if (id != GLOBAL_ZONEID) + return (EINVAL); ssize_t ret = strlen(GLOBAL_ZONEID_NAME) + 1; - if(buf == NULL || buflen == 0) - return ret; + if (buf == NULL || buflen == 0) + return (ret); strncpy(buf, GLOBAL_ZONEID_NAME, buflen); buf[buflen - 1] = '\0'; - return ret; + return (ret); } diff --git a/lib/libzfs/libzfs_fru.c b/lib/libzfs/libzfs_fru.c index 4e2fe9d07..6be927f80 100644 --- a/lib/libzfs/libzfs_fru.c +++ b/lib/libzfs/libzfs_fru.c @@ -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 */ - - diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index d1fa98e67..b5a079c0e 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -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; diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 68e4ef4de..3cd6406b2 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -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, diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index ccaa86bea..b822ace68 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -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); } diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 54dc2afc5..706ae1769 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -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, diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index f994f8ee3..05bbd06cc 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -74,7 +74,7 @@ thread_init(void) VERIFY3S(pthread_key_create(&kthread_key, NULL), ==, 0); /* Create entry for primary kthread */ - kt = umem_zalloc(sizeof(kthread_t), UMEM_NOFAIL); + kt = umem_zalloc(sizeof (kthread_t), UMEM_NOFAIL); kt->t_tid = pthread_self(); kt->t_func = NULL; @@ -93,7 +93,7 @@ thread_fini(void) ASSERT(pthread_equal(kt->t_tid, pthread_self())); ASSERT3P(kt->t_func, ==, NULL); - umem_free(kt, sizeof(kthread_t)); + umem_free(kt, sizeof (kthread_t)); /* Wait for all threads to exit via thread_exit() */ VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0); @@ -117,7 +117,7 @@ zk_thread_current(void) ASSERT3P(kt, !=, NULL); - return kt; + return (kt); } void * @@ -137,12 +137,12 @@ zk_thread_helper(void *arg) /* Unreachable, thread must exit with thread_exit() */ abort(); - return NULL; + return (NULL); } kthread_t * zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg, - size_t len, proc_t *pp, int state, pri_t pri, int detachstate) + size_t len, proc_t *pp, int state, pri_t pri, int detachstate) { kthread_t *kt; pthread_attr_t attr; @@ -150,7 +150,7 @@ zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg, ASSERT3S(state & ~TS_RUN, ==, 0); - kt = umem_zalloc(sizeof(kthread_t), UMEM_NOFAIL); + kt = umem_zalloc(sizeof (kthread_t), UMEM_NOFAIL); kt->t_func = func; kt->t_arg = arg; @@ -188,7 +188,7 @@ zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg, VERIFY3S(pthread_attr_destroy(&attr), ==, 0); - return kt; + return (kt); } void @@ -198,7 +198,7 @@ zk_thread_exit(void) ASSERT(pthread_equal(kt->t_tid, pthread_self())); - umem_free(kt, sizeof(kthread_t)); + umem_free(kt, sizeof (kthread_t)); pthread_mutex_lock(&kthread_lock); kthread_nr--; @@ -737,7 +737,7 @@ vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset, * (memory or disk) due to O_DIRECT, so we abort() in order to * catch the offender. */ - abort(); + abort(); } #endif if (rc == -1) diff --git a/lib/libzpool/taskq.c b/lib/libzpool/taskq.c index 96c0d5c2b..72807f6a3 100644 --- a/lib/libzpool/taskq.c +++ b/lib/libzpool/taskq.c @@ -157,7 +157,7 @@ taskq_dispatch_delay(taskq_t *tq, task_func_t func, void *arg, uint_t tqflags, int taskq_empty_ent(taskq_ent_t *t) { - return t->tqent_next == NULL; + return (t->tqent_next == NULL); } void @@ -287,7 +287,8 @@ taskq_create(const char *name, int nthreads, pri_t pri, tq->tq_maxalloc = maxalloc; tq->tq_task.tqent_next = &tq->tq_task; tq->tq_task.tqent_prev = &tq->tq_task; - tq->tq_threadlist = kmem_alloc(nthreads*sizeof(kthread_t *), KM_SLEEP); + tq->tq_threadlist = kmem_alloc(nthreads * sizeof (kthread_t *), + KM_SLEEP); if (flags & TASKQ_PREPOPULATE) { mutex_enter(&tq->tq_lock); |