- don't initialize a variable unnecessarily. + this confuses the human reader -- she thinks the initialization has some meaning, but it does not
+ this prevents automatic tools from discovering paths were the variable will not be set before being used. (Technically the spurious initialization prevents this bug but logically it is covering it up.) This complements previous hints: - declare auto variables as late as possible. Especially nice if this can be combined with the first assignment (often the only assignment) + this reduces the region of code in which the variable is undefined (i.e. can be mentioned but is meaningless) - declare auto variables as deep within nested blocks as is convenient + this reduces the scope of the variable and thus the amount of code that must be read to understand the variables meaning Similarly: - as many globals as possible should be made file-static. + this reduces the scope and thus makes it easier to understand the object - as many file statics as possible should be made autos or function-statics + same reason - as many pointers as possible should be made to be pointers to const. + makes understanding dataflow a lot easier _______________________________________________ Swan-dev mailing list Swan-dev@lists.libreswan.org https://lists.libreswan.org/mailman/listinfo/swan-dev