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

Constify argv, fix warnings. #1242

Merged
merged 3 commits into from Jan 5, 2024
Merged

Constify argv, fix warnings. #1242

merged 3 commits into from Jan 5, 2024

Conversation

hramrach
Copy link
Contributor

rrd has no business modifying the string pointed to by passed agrv, and
as far as gcc can see it does indeed not modify them because it compiles
with const argv.

This fixes warnings when passing const strings into rrd, and avoids the
need to duplicate all strings in tcl bindings.

This fixes warnings like these:
[    3s] prog/sensord/rrd.c: In function 'rrdInit':
[    3s] prog/sensord/rrd.c:302:40: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
[    3s]   302 |                 ret = rrd_create(argc, (char**) argv);
[    3s]       |                                        ^
[    3s] prog/sensord/rrd.c: In function 'rrdUpdate':
[    3s] prog/sensord/rrd.c:458:42: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
[    3s]   458 |                 if ((ret = rrd_update(3, (char **) /* WEAK */ argv))) {
[    3s]       |                                          ^

 - cast POPs to void to avoid unused value warning
 - declare functions that don't set RETVAL as returning void

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Copy link

codecov bot commented Dec 26, 2023

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (c1be8ba) 51.01% compared to head (058bc3c) 51.02%.

Files Patch % Lines
src/rrd_cgi.c 0.00% 5 Missing ⚠️
src/rrdupdate.c 0.00% 4 Missing ⚠️
src/optparse.c 66.66% 2 Missing ⚠️
src/rrd_tool.c 33.33% 2 Missing ⚠️
src/rrd_lastupdate.c 0.00% 1 Missing ⚠️
src/rrd_resize.c 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1242   +/-   ##
=======================================
  Coverage   51.01%   51.02%           
=======================================
  Files          45       45           
  Lines       18213    18214    +1     
=======================================
+ Hits         9291     9293    +2     
+ Misses       8922     8921    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oetiker
Copy link
Owner

oetiker commented Jan 3, 2024

@hramrach thanks for the patch! Please update the CHANGES file as well, then I think we are ready to merge.

@c72578

This comment was marked as outdated.

@c72578

This comment was marked as resolved.

c72578
c72578 previously approved these changes Jan 3, 2024
CHANGES Outdated Show resolved Hide resolved
rrd has no business modifying the string pointed to by passed agrv, and
as far as gcc can see it does indeed not modify them because it compiles
with const argv.

This fixes warnings when passing const strings into rrd, and avoids the
need to duplicate all strings in the tcl bindings.

This fixes warnings like these:
[    3s] prog/sensord/rrd.c: In function 'rrdInit':
[    3s] prog/sensord/rrd.c:302:40: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
[    3s]   302 |                 ret = rrd_create(argc, (char**) argv);
[    3s]       |                                        ^
[    3s] prog/sensord/rrd.c: In function 'rrdUpdate':
[    3s] prog/sensord/rrd.c:458:42: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
[    3s]   458 |                 if ((ret = rrd_update(3, (char **) /* WEAK */ argv))) {
[    3s]       |                                          ^

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
@oetiker oetiker merged commit b76e3c5 into oetiker:master Jan 5, 2024
7 of 9 checks passed
yselkowitz added a commit to yselkowitz/lm-sensors that referenced this pull request Feb 11, 2024
rrdtool has applied a patch to constify all argv parameters, which fixes
incompatible pointer type errors with GCC 14.  This patch adapts
accordingly, but would trigger similar errors against an rrdtool without
that change.

oetiker/rrdtool-1.x#1242

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants