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

huawei-ups2000.c: rename NULL macros, close #1474. #1515

Merged
merged 1 commit into from
Jul 23, 2022

Conversation

biergaizi
Copy link
Contributor

@biergaizi biergaizi commented Jul 23, 2022

Originally, in the struct array ups2000_cmd[], a REG_NONE macro was used as a short-hand for a nonexistent register value. Unfortunately it was in conflict with a Windows NT macro of the same name (previously not found because it was only tested on Unix systems). Thus, this commit renames it to REG_NULL. To avoid visual confusions with the function pointer field (which also uses C's NULL for its nonexistence), this commit also replaces it with a new macro FUNC_NULL, which is a simple alias to C's NULL.

It's not exactly the best practice, a UPS2000_ prefix should've been used in principle. However, using it in this case creates exceedingly long lines and makes the struct array definition more difficult to read, which defeats the very purpose of defining these macros to begin with. Considering that it's only an one-off use, it's unlikely to cause further problems.

This PR closes #1474.

Originally, in the struct array ups2000_cmd[], a REG_NONE macro was used
as a short-hand for a nonexistent register value. Unfortunately it was
in conflict with a Windows NT macro of the same name (previously not
found because it was only tested on Unix systems). Thus, this commit
renames it to REG_NULL. To avoid visual confusions with the function
pointer field (which also uses C's NULL for its nonexistence), this
commit also replaces it with a new macro FUNC_NULL, which is a simple
alias to C's NULL.

It's not exactly the best practice, a "UPS2000_" prefix should've been
used in principle. However, using it in this case creates exceedingly
long lines and makes the struct array definition more difficult to read,
which defeats the very purpose of defining these macros to begin with.
Considering that it's only an one-off use, it's unlikely to cause further
problems.

Signed-off-by: Yifeng Li <tomli@tomli.me>
@jimklimov
Copy link
Member

Thanks for taking care of this on short notice :)

@jimklimov jimklimov merged commit f7ca8de into networkupstools:master Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

huawei-ups2000.c:1434: warning: "REG_NONE" redefined (WIN32 builds)
2 participants