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

Fix debug print of excluderegex if NULL #3893

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

sonertari
Copy link

@sonertari sonertari commented Jul 19, 2021

ChangeLog: match utility: The printing of a NULL pointer in debug mode has been fixed.

excluderegex in logparser plugin is optional, hence can be NULL. If debug is enabled, debug print causes a CRITICAL error log like vfprintf %s NULL in "utils_match: match_create_callback: regex = %s, excluderegex = %s"
@sonertari sonertari requested a review from a team as a code owner July 19, 2021 14:35
@collectd-bot collectd-bot added this to the 6.0 milestone Jul 19, 2021
@@ -204,7 +204,7 @@ match_create_callback(const char *regex, const char *excluderegex,
int status;

DEBUG("utils_match: match_create_callback: regex = %s, excluderegex = %s",
regex, excluderegex);
regex, excluderegex != NULL ? excluderegex : "");
Copy link
Member

Choose a reason for hiding this comment

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

Personally I would change it to something more meaningful than empty string, which is not visible for the user, like:
excluderegex != NULL ? excluderegex : "NULL" or excluderegex != NULL ? excluderegex : "''".

Copy link
Author

Choose a reason for hiding this comment

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

I see that in similar cases the collectd source code prints the following:

  • "(null)" in src/configfile.c
  • "<NULL>" in src/utils_curl_stats.c
  • "(nil)" in src/netlink.c
  • "" in src/nginx.c (as in my pr)

Your suggestion would be fine with me, but it will add yet another variation to the list. As you (the collectd contributors) wish.

Copy link
Member

Choose a reason for hiding this comment

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

So we can choose existing one to not add another variation, I would choose between "(null)" or "<NULL>".

@mrunge mrunge merged commit 9dc1291 into collectd:collectd-6.0 Sep 6, 2021
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.

None yet

4 participants