summaryrefslogtreecommitdiffstats
path: root/lib/libefi
diff options
context:
space:
mode:
authorMichael Kjorling <[email protected]>2013-11-01 20:26:11 +0100
committerBrian Behlendorf <[email protected]>2013-12-18 16:46:35 -0800
commitd1d7e2689db9e03f11c069ebc9f1ba12829e5dac (patch)
tree75b9a2b23334d5f673fb31f142f74146d351865c /lib/libefi
parent8ffef572ed2ba97e0c2d6a8aa2240012e611dc6f (diff)
cstyle: Resolve C style issues
The vast majority of these changes are in Linux specific code. They are the result of not having an automated style checker to validate the code when it was originally written. Others were caused when the common code was slightly adjusted for Linux. This patch contains no functional changes. It only refreshes the code to conform to style guide. Everyone submitting patches for inclusion upstream should now run 'make checkstyle' and resolve any warning prior to opening a pull request. The automated builders have been updated to fail a build if when 'make checkstyle' detects an issue. Signed-off-by: Brian Behlendorf <[email protected]> Closes #1821
Diffstat (limited to 'lib/libefi')
-rw-r--r--lib/libefi/rdwr_efi.c93
1 files changed, 47 insertions, 46 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, &sector_size) < 0)
- return (-1);
+ if (ioctl(fd, BLKSSZGET, &sector_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);