Re: [PATCH] main: Use static global rather than 'General' string literal.
Grant Erickson <[email protected]>
| Newsgroups | dev.linux.lists.connman |
|---|---|
| Message-ID | <[email protected]> |
On Dec 28, 2023, at 1:54 AM, Marcel Holtmann <[email protected]> wrote: >>>> This converts a potential run time error due to a mis-spelling of the >>>> "General" configuration group name repeatedly used a string literal >>>> into a potential compile time error due to a mis-spelling of the >>>> static global that now references it once and only once. >>>> --- >>>> src/main.c | 85 +++++++++++++++++++++++++++++++----------------------- >>>> 1 file changed, 49 insertions(+), 36 deletions(-) >>> >>> wouldn’t be >>> >>> #define GENERAL_GROUP “General” >>> >>> or >>> >>> #define GROUP_GENERAL “General” >>> >>> be actually more consistent with the other constants we use here. >> >> There are definitely an appreciable number of existing preprocessor definitions in this file. So, with that in mind, a preprocessor definition would be stylistically more consistent. >> >>> I do like the all upper-case to indicate a constant here (and scrapping >>> the “name” portion). >>> >>> Otherwise, yes, it is stupid from us to keep using “General” in all >>> places :( >> >> At -O2 optimization, all three approaches are neutral from a code-generation perspective. So, the question comes down to one of style: >> >> [ … ] >> >> I’d be happy to re-submit a v2 patch with the preprocessor definition. > > then lets use the preprocessor macro. We defiantly have used that more > than the global string. Marcel, Submitted as v2. Best, Grant -- Principal Nuovations [email protected] http://www.nuovations.com/