Skip to content

Conversation

@dwsteele
Copy link
Collaborator

@dwsteele dwsteele commented May 21, 2025

The compiler warns that this branch is unreachable:

src/set_user.c:241:26: warning: the comparison will always evaluate as 'true' for the address of 'data' will never be NULL [-Waddress]
  241 |                 else if (!NameStr(procStruct->proname))
      |                          ^
In file included from /usr/include/postgresql/17/server/postgres.h:45,
                 from src/set_user.c:28:
/usr/include/postgresql/17/server/c.h:742:25: note: 'data' declared here
  742 |         char            data[NAMEDATALEN];
      |                         ^~~~

This warning goes all the way back to PG12 so the code has not been valid for at this long. One solution would be to change the branch to:

else if (NameStr(procStruct->proname)[0] == '\0')

However, it is not clear that this will ever be true. If SearchSysCache1() returned successfully presumably the name got filled in.

Overall it seems best to just remove the branch since it leaves us no worse off than we were before. This will allow us to enable error on warnings since this is the only warning currently.

@dwsteele dwsteele self-assigned this May 21, 2025
@dwsteele dwsteele requested a review from pgguru May 21, 2025 21:12
@pgguru
Copy link
Collaborator

pgguru commented May 22, 2025

I've run into this before and agree we can count on SearchSysCache doing the right thing and just removing the check.

@dwsteele dwsteele merged commit 6ec2774 into pgaudit:integration May 22, 2025
6 checks passed
@dwsteele dwsteele deleted the dev-remove-dead-branch branch May 22, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants