Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/cgdconfig KNF, 80 column police, a few other tidy ups (...



details:   https://anonhg.NetBSD.org/src/rev/8e729cce1b80
branches:  trunk
changeset: 450310:8e729cce1b80
user:      kre <kre%NetBSD.org@localhost>
date:      Wed Apr 10 06:11:37 2019 +0000

description:
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.

diffstat:

 sbin/cgdconfig/cgdconfig.c |  31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diffs (104 lines):

diff -r 8d9f2ad8aa5d -r 8e729cce1b80 sbin/cgdconfig/cgdconfig.c
--- a/sbin/cgdconfig/cgdconfig.c        Wed Apr 10 06:09:39 2019 +0000
+++ b/sbin/cgdconfig/cgdconfig.c        Wed Apr 10 06:11:37 2019 +0000
@@ -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 @@
                        (void)unconfigure_fd(fd);
                        goto bail_err;
                }
-               if (!ret)
+               if (ret == 0)           /* success */
                        break;
 
                (void)unconfigure_fd(fd);
@@ -646,7 +646,8 @@
        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 @@
 {
        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 @@
        }
 
        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 @@
 
                /* 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 @@
        }
 
        return params_cput(p, outfile);
-bail:
+ bail:;
        params_free(oldp);
        return -1;
 }
@@ -1141,7 +1144,7 @@
                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 @@
                printf("%s ", iv_method(cgu.cgu_mode));
        }
 
-out:
+ out:;
        putchar('\n');
        close(fd);
 }



Home | Main Index | Thread Index | Old Index