Module Name: src
Committed By: kre
Date: Wed Apr 10 06:11:37 UTC 2019
Modified Files:
src/sbin/cgdconfig: cgdconfig.c
Log Message:
KNF, 80 column police, a few other tidy ups (use if (ret == 0) rather
than if (!ret) when ret is not a boolean, and test fopen result against
NULL, for example).
NFCI.
To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sbin/cgdconfig/cgdconfig.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/cgdconfig/cgdconfig.c
diff -u src/sbin/cgdconfig/cgdconfig.c:1.49 src/sbin/cgdconfig/cgdconfig.c:1.50
--- src/sbin/cgdconfig/cgdconfig.c:1.49 Wed Apr 10 06:09:39 2019
+++ src/sbin/cgdconfig/cgdconfig.c Wed Apr 10 06:11:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cgdconfig.c,v 1.49 2019/04/10 06:09:39 kre Exp $ */
+/* $NetBSD: cgdconfig.c,v 1.50 2019/04/10 06:11:37 kre Exp $ */
/*-
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 2002, 2003\
The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: cgdconfig.c,v 1.49 2019/04/10 06:09:39 kre Exp $");
+__RCSID("$NetBSD: cgdconfig.c,v 1.50 2019/04/10 06:11:37 kre Exp $");
#endif
#include <err.h>
@@ -629,7 +629,7 @@ configure(int argc, char **argv, struct
(void)unconfigure_fd(fd);
goto bail_err;
}
- if (!ret)
+ if (ret == 0) /* success */
break;
(void)unconfigure_fd(fd);
@@ -646,7 +646,8 @@ configure(int argc, char **argv, struct
params_free(p);
(void)prog_close(fd);
return 0;
-bail_err:
+
+ bail_err:;
params_free(p);
(void)prog_close(fd);
return -1;
@@ -703,7 +704,7 @@ opendisk_werror(const char *cgd, char *b
{
int fd;
- VPRINTF(3, ("opendisk_werror(%s, %s, %zu) called.\n", cgd, buf, buflen));
+ VPRINTF(3, ("opendisk_werror(%s, %s, %zu) called.\n", cgd,buf,buflen));
/* sanity */
if (!cgd || !buf)
@@ -919,14 +920,14 @@ verify_gpt(int fd)
}
ret = 1;
- for (blksize=DEV_BSIZE;
- (off = blksize * GPT_HDR_BLKNO) <= SCANSIZE - sizeof(hdr);
+ for (blksize = DEV_BSIZE;
+ (off = (blksize * GPT_HDR_BLKNO)) <= SCANSIZE - sizeof(hdr);
blksize <<= 1) {
memcpy(&hdr, &buf[off], sizeof(hdr));
- if (memcmp(hdr.hdr_sig, GPT_HDR_SIG, sizeof(hdr.hdr_sig)) == 0 &&
- le32toh(hdr.hdr_revision) == GPT_HDR_REVISION &&
- le32toh(hdr.hdr_size) == GPT_HDR_SIZE) {
+ if (memcmp(hdr.hdr_sig, GPT_HDR_SIG, sizeof(hdr.hdr_sig)) == 0
+ && le32toh(hdr.hdr_revision) == GPT_HDR_REVISION
+ && le32toh(hdr.hdr_size) == GPT_HDR_SIZE) {
hdr.hdr_crc_self = 0;
if (crc32(&hdr, sizeof(hdr))) {
@@ -993,7 +994,9 @@ verify_reenter(struct params *p)
/* add a compat flag till the _OLD method goes away */
key = getkey_pkcs5_pbkdf2("re-enter device", kg,
- bits_len(orig_key), kg->kg_method == KEYGEN_PKCS5_PBKDF2_OLD);
+ bits_len(orig_key),
+ kg->kg_method == KEYGEN_PKCS5_PBKDF2_OLD);
+
ret = !bits_match(key, orig_key);
bits_free(key);
@@ -1113,7 +1116,7 @@ generate_convert(struct params *p, int a
}
return params_cput(p, outfile);
-bail:
+ bail:;
params_free(oldp);
return -1;
}
@@ -1141,7 +1144,7 @@ do_all(const char *cfile, int argc, char
fn = cfile;
f = fopen(fn, "r");
- if (!f) {
+ if (f == NULL) {
warn("could not open config file \"%s\"", fn);
return -1;
}
@@ -1222,7 +1225,7 @@ show(const char *dev) {
printf("%s ", iv_method(cgu.cgu_mode));
}
-out:
+ out:;
putchar('\n');
close(fd);
}