Page MenuHomeFreeBSD

usr.sbin/ntp/libopts: build time warning fixes
Needs ReviewPublic

Authored by aprieger_llnw.com on Jun 2 2017, 4:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 14, 2:04 AM
Unknown Object (File)
Dec 20 2023, 8:29 AM
Unknown Object (File)
Nov 18 2023, 6:22 AM
Unknown Object (File)
Nov 18 2023, 4:56 AM
Unknown Object (File)
Nov 18 2023, 4:34 AM
Unknown Object (File)
Oct 12 2023, 11:28 AM
Unknown Object (File)
Aug 31 2023, 3:25 AM
Unknown Object (File)
Jul 9 2023, 5:14 AM
Subscribers
None

Details

Summary

Added a function to autoops.c and distributed throughout the application that is created with a purpose to fix or suppress warnings at buildtime for the following applications in the libopts folder: enum.c ; find.c ; makeshell.c ; nested.c ; pgusage.c ; putshell.c ; save.c ; usage.c. The specific warning was consistent throughout the applications: "warning: format string contains '\0' within the string body [-Wformat] "This warning is caused by the design of the message system for the libopts applications when printing using a certain format string that utilizes one char array separating each format with the null character'\0'. However when building, the compiler throws a warning. So in order to suppress the warning, the function takes the long string of formats at a certain offset, then returns the same input thereby interpreting the string up to the null character, and normalizing the format string.

Diff Detail

Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 9630
Build 10072: arc lint + arc unit

Event Timeline

Changelog:
Pre-fix warnings are at: https://gist.github.com/aprieger-llnw/17436862ce2d27511eb0ba95d8e08e0a

  1. contrib/ntp/sntp/libopts/autoopts.c
    • Added a getWformatFree( ) function that merely return the const char* contents of the const char* input, to normalize the data
    • More documentation located in code
    • The strings are derived from two files: ao-strs.c and ao-strs.h which define the message structure and macros used by the applications
  2. contrib/ntp/sntp/libopts/enum.c
    • Warnings: this warning is consistent through the entire application
      • warning: format string contains '\0' within the string body [-Wformat]
    • Fixes:
      • Utilized getWformatFree( ) on the format strings of various print statements at lines 112, 135, 148, 155, 307 to suppress the warnings
  3. contrib/ntp/sntp/libopts/find.c
    • Warnings: this warning is consistent through the entire application
      • warning: format string contains '\0' within the string body [-Wformat]
    • Fixes:
      • Utilized getWformatFree( ) on the format strings of various print statements at lines 114, 119, 219, 432 to suppress the warnings
  4. contrib/ntp/sntp/libopts/makeshell.c
    • Warnings: this warning is consistent through the entire application
      • warning: format string contains '\0' within the string body [-Wformat]
    • Fixes:
      • Utilized getWformatFree( ) on the format strings of various print statements at lines 152, 162, 171, 183, 189, 200, 235, 386, 388, 391, 441, 537, 540, 543, 544, 549, 550, 552, 556, 559, 562, 569, 570, 573, 574, 577, 587, 590, 593, 596, 619, 694, 704 to suppress the warnings
  5. contrib/ntp/sntp/libopts/pgusage.c
    • Warnings: this warning is consistent through the entire application
      • warning: format string contains '\0' within the string body [-Wformat]
    • Fixes:
      • Utilized getWformatFree( ) on the format strings of various print statements at lines 48, 90 to suppress the warnings
  6. contrib/ntp/sntp/libopts/nested.c
    • Warnings: this warning is consistent through the entire application
      • warning: format string contains '\0' within the string body [-Wformat]
    • Fixes:
      • Utilized getWformatFree( ) on the format strings of various print statements at lines 928 to suppress the warnings
  7. contrib/ntp/sntp/libopts/putshell.c
    • Warnings: this warning is consistent through the entire application
      • warning: format string contains '\0' within the string body [-Wformat]
    • Fixes:
      • Utilized getWformatFree( ) on the format strings of various print statements at lines 190, 277, 283, 288, 297, 315, 330, 333, 336, 375, 403, 440, 451, 471, 483, 491, 493 to suppress the warnings
  8. contrib/ntp/sntp/libopts/save.c
    • Warnings: this warning is consistent through the entire application
      • warning: format string contains '\0' within the string body [-Wformat]
    • Fixes:
      • Utilized getWformatFree( ) on the format strings of various print statements at lines 351, 366, 386, 392, 396, 411, 439, 459, 463, 503, 556 to suppress the warnings
  9. contrib/ntp/sntp/libopts/usage.c
    • Warnings: this warning is consistent through the entire application
      • warning: format string contains '\0' within the string body [-Wformat]
    • Fixes:
      • Utilized getWformatFree( ) on the format strings of various print statements at lines 352, 357, 437 to suppress the warnings