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

mgmtd: Ensure map is NULL #16677

Merged
merged 1 commit into from
Aug 28, 2024
Merged

mgmtd: Ensure map is NULL #16677

merged 1 commit into from
Aug 28, 2024

Conversation

donaldsharp
Copy link
Member

Build is complaining:
build 27-Aug-2024 05:46:38 mgmtd/mgmt_be_adapter.c: In function ‘mgmt_register_client_xpath’: build 27-Aug-2024 05:46:38 mgmtd/mgmt_be_adapter.c:274:27: warning: ‘maps’ may be used uninitialized [-Wmaybe-uninitialized]
build 27-Aug-2024 05:46:38 274 | map = darr_append(*maps);
build 27-Aug-2024 05:46:38 | ^
build 27-Aug-2024 05:46:38 mgmtd/mgmt_be_adapter.c:250:36: note: ‘maps’ was declared here
build 27-Aug-2024 05:46:38 250 | struct mgmt_be_xpath_map **maps, *map;
build 27-Aug-2024 05:46:38 | ^~~~

Let's make the compiler happy, even though there is no problem.

Build is complaining:
build	27-Aug-2024 05:46:38	mgmtd/mgmt_be_adapter.c: In function ‘mgmt_register_client_xpath’:
build	27-Aug-2024 05:46:38	mgmtd/mgmt_be_adapter.c:274:27: warning: ‘maps’ may be used uninitialized [-Wmaybe-uninitialized]
build	27-Aug-2024 05:46:38	  274 |         map = darr_append(*maps);
build	27-Aug-2024 05:46:38	      |                           ^
build	27-Aug-2024 05:46:38	mgmtd/mgmt_be_adapter.c:250:36: note: ‘maps’ was declared here
build	27-Aug-2024 05:46:38	  250 |         struct mgmt_be_xpath_map **maps, *map;
build	27-Aug-2024 05:46:38	      |                                    ^~~~

Let's make the compiler happy, even though there is no problem.

Signed-off-by: Donald Sharp <[email protected]>
@frrbot frrbot bot added the mgmt FRR Management Infra label Aug 28, 2024
@@ -249,6 +249,8 @@ static void mgmt_register_client_xpath(enum mgmt_be_client_id id,
{
struct mgmt_be_xpath_map **maps, *map;

maps = NULL;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we going to get a report down after line 267, because we could be deref'ing maps when it's NULL ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all 4 cases that are available are in the switch

enum mgmt_be_xpath_subscr_type {
MGMT_BE_XPATH_SUBSCR_TYPE_CFG,
MGMT_BE_XPATH_SUBSCR_TYPE_OPER,
MGMT_BE_XPATH_SUBSCR_TYPE_NOTIF,
MGMT_BE_XPATH_SUBSCR_TYPE_RPC,
};

I don't see a path that would actually cause this problem, but the compiler is complaining about something that it should not be complaining. I'm just making it happy

@Jafaral Jafaral merged commit 04b763b into FRRouting:master Aug 28, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master mgmt FRR Management Infra size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants