OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
958 stars 174 forks source link

Fixed a couple of gcc warnings #887

Closed alexpevzner closed 5 months ago

alexpevzner commented 5 months ago

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.

alexpevzner commented 5 months ago

Done