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

Fixed a couple of gcc warnings #887

Merged

Conversation

alexpevzner
Copy link
Member

In cups/dest.c:

dest.c:1830:21: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
 1733 |       DEBUG_printf(("1cupsGetNamedDest: Using name=\"%s\"...", name));
  |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is really true, and gcc was smart enough to deduct it from context. Obviously, we meant to print dest_name here.

In cgi-bin/search.c:

search.c:191:29: warning: pointer ‘s’ may be used after ‘realloc’ [-Wuse-after-free]
  191 |         sptr = temp + (sptr - s);
  |                       ~~~~~~^~~~

The code is correct, but too hard for gcc to analyze. So code simplified a bit to make compiler happy.

Copy link
Member

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

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

Please omit the (sptr - s) change and update the debug printf.

cgi-bin/search.c Outdated Show resolved Hide resolved
cups/dest.c Outdated Show resolved Hide resolved
In cups/dest.c:

    dest.c:1830:21: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
     1733 |       DEBUG_printf(("1cupsGetNamedDest: Using name=\"%s\"...", name));
	  |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is really true, and gcc was smart enough to deduct it from context.
Obviously, we meant to print dest_name here.
@alexpevzner alexpevzner force-pushed the cups-pzz-master-fix-warnings branch from 72b2171 to cac443f Compare February 8, 2024 16:01
@alexpevzner
Copy link
Member Author

Done

Copy link
Member

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

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

+1

@alexpevzner alexpevzner merged commit 01e9616 into OpenPrinting:master Feb 9, 2024
4 of 6 checks passed
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.

3 participants