Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recommended lgtm issues: #126

Closed
avan989 opened this issue Dec 20, 2019 · 2 comments · Fixed by #235 or #243
Closed

recommended lgtm issues: #126

avan989 opened this issue Dec 20, 2019 · 2 comments · Fixed by #235 or #243
Labels
Milestone

Comments

@avan989
Copy link
Contributor

avan989 commented Dec 20, 2019

Is your feature request related to a problem? Please describe.
Recommended issue from lgtm:

cfe_psp_module.h

typedef enum
--
37 | {
  | In an enumerator list, the = construct should not be used to explicitly initialize members other than the first, unless all items are explicitly initialized.
38 | CFE_PSP_MODULE_TYPE_INVALID = 0,
39 | CFE_PSP_MODULE_TYPE_VALID_RANGE  = 1000,
@skliper
Copy link
Contributor

skliper commented Dec 22, 2019

Definitely worth clarifying.

typedef enum
{
CFE_PSP_MODULE_TYPE_INVALID = 0,
CFE_PSP_MODULE_TYPE_VALID_RANGE = 1000,
CFE_PSP_MODULE_TYPE_SIMPLE,
/* May be extended in the future */
CFE_PSP_MODULE_TYPE_MAX
} CFE_PSP_ModuleType_t;

Should be understandable at a quick glance. @jphickey any suggestions? Not clear to me what the intent is here.

@jphickey
Copy link
Contributor

It is simply intended to provide unique(-ish) numeric values for the valid enumerators. If every enumeration in the system starts with 1, then it is easy to interchange. Using a starting value other than 1 offers a modicum of protection against using incorrect values (i.e. if someone passed a pointer to the wrong struct, or something).

I'm not sure why this is an lgtm "issue" as it is pretty well defined in the C standard how enum declarations work. But if you'd rather start with 1, it won't change the behavior, but it will make it a little less secure.

@skliper skliper added the enhancement New feature or request label Jan 7, 2020
skliper added a commit to skliper/PSP that referenced this issue Jan 6, 2021
Avoids irregular enum warning
skliper added a commit to skliper/PSP that referenced this issue Jan 13, 2021
Avoids irregular enum warning
@astrogeco astrogeco added refactor and removed enhancement New feature or request labels Jan 25, 2021
@astrogeco astrogeco added this to the 1.6.0 milestone Jan 25, 2021
astrogeco added a commit that referenced this issue Jan 25, 2021
Fix #126, Refactor CFE_PSP_ModuleType_t enum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants