Skip to content

Commit

Permalink
test: avoid side effects within assert() call
Browse files Browse the repository at this point in the history
This fixes a false positive from cppcheck(1): all modules under
tests/ have NDEBUG defined
  • Loading branch information
dacav committed Jan 16, 2025
1 parent ad11405 commit ecc6213
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/get_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,10 @@ int main(void) {
const struct passwd *pwd;
char *username;

assert((pwd = getpwuid(geteuid())) != NULL);
assert((username = strdup(pwd->pw_name)) != NULL);
pwd = getpwuid(geteuid());
assert(pwd != NULL);
username = strdup(pwd->pw_name);
assert(username != NULL);

test_nouserok(username);
test_ssh_credential(username);
Expand Down

0 comments on commit ecc6213

Please sign in to comment.