Source-Changes archive

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

CVS commit: src/sys/dev/i2c



Module Name:    src
Committed By:   riastradh
Date:           Wed Nov  6 15:49:36 UTC 2024

Modified Files:
        src/sys/dev/i2c: ds2482ow.c ds2482owvar.h

Log Message:
ds2482ow(4): KNF

No functional change intended.

Non-whitespace changes:

1. Sort includes.

2. Say `if (sc->sc_is_800)', not `if (sc->sc_is_800 == true)'; no
   need to have multiple redundant verbs and boolean tests in this
   phrasing.

3. Use __nothing (a statement that has no effect), not empty token
   sequence, for macros that have no effect.  This avoids potential
   confusion in places that expect exactly one statement.  (If this
   change does have a functional effect, well, something must have
   been broken before!)

4. Omit needless `return;' at the end of void functions.
   (ds2482_attach still needs something after `out:', though, and
   `out: return;' is a little less obscure than `out:;'.)

Some of this nesting is a little excessive.  It would help legibility
and avoid excessive nesting depth to rephrase things like

        error = foo();
        if (!error)
                error = bar();
        if (!error) {
                error = baz();
                if (!error)
                        error = quux();
                if (!error) {
                        error = zot();
                        if (!error) {
                                error = mumble();
                                if (!error) {
                                        error = frotz();
                                        if (!error) {
                                                *obuf = xbuf;
                                        }
                                }
                        }
                }
        }

as

        error = foo();
        if (error)
                goto out;               /* or break, in this case */
        error = bar();
        if (error)
                goto out;
        error = baz();
        if (error)
                goto out;
        error = quux();
        if (error)
                goto out;
        error = zot();
        if (error)
                goto out;
        error = mumble();
        if (error)
                goto out;
        error = frotz();
        if (error)
                goto out;
        *obuf = xbuf;

so that the indentation level doesn't grow indefinitely and the
expected-taken normal path remains unindented while the
expected-not-taken error branches get indentation.  (But that's a lot
more churn to the code, and more error-prone, than seemed appropriate
here.)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/ds2482ow.c \
    src/sys/dev/i2c/ds2482owvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index