Page MenuHomeFreeBSD

gnu/usr.bin/grep some build warning fixes
Needs ReviewPublic

Authored by aprieger_llnw.com on Jun 13 2017, 6:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 4:58 PM
Unknown Object (File)
Tue, Apr 16, 4:57 PM
Unknown Object (File)
Dec 20 2023, 3:14 AM
Unknown Object (File)
Nov 18 2023, 5:00 AM
Unknown Object (File)
Nov 18 2023, 5:00 AM
Unknown Object (File)
May 7 2023, 6:04 PM
Unknown Object (File)
May 4 2023, 4:24 PM
Subscribers

Details

Reviewers
kbowling
sbruno
Summary

Code changes to fix warnings during build time for the application gnu/usr.bin/grep

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 9853
Build 10288: arc lint + arc unit

Event Timeline

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

  1. gnu/usr.bin/grep/dfa.c
    • warning: passing 'const unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
      • fix: explicitly cast the parameters to (const char *) on lines 386, 2511, 2518, 2531, 2786
    • warning: incompatible pointer types assigning to 'wchar_t *' (aka 'int *') from 'wctype_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]
      • fix: Separate the line 488 into two lines, individually assigning them to NULL
    • warning: incompatible pointer types assigning to 'wctype_t *' (aka 'unsigned long *') from 'wchar_t *' (aka 'int *') [-Wincompatible-pointer-types]
      • fix: changed the second parameter of MALLOC call on line 557 to wctype_t, which is the correct type of the first parameter which needs toe be equal to allocate the correct memory
    • warning: passing 'const char *' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Wpointer-sign]
      • fix: fixed the FETCH macro by casting the first parameter to (const unsigned char *) for the function called within the macro that had an incorrect type of parameter being used in the call affecting lines 729, 877, 883, 893, 901, 916, 1004, 1007, 1031, 1035, 1036, 1039, 1051, 1052,
  2. gnu/usr.bin/grep/dfa.c
    • warning: shifting a negative signed value is undefined [-Wshift-negative-value]
      • NO FIX: unable to find solution without mutating the results, may need warning suppression for lines 1410, 1593
  3. gnu/usr.bin/grep/search.c
    • warning: format string is not a string literal (potentially insecure) [-Wformat-security]
      • fix: Added the %s modifier to the print statements on lines 108, 147, 156, 159, 203, 287, 758, 781, 793, 807, 815

Note: Remaining warnings:

  • /usr/home/aprieger/repos/freebsd_master/freebsd/gnu/usr.bin/grep/grep.c:1410:15: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
  • /usr/home/aprieger/repos/freebsd_master/freebsd/gnu/usr.bin/grep/grep.c:1593:20: warning: shifting a negative signed value is undefined [-Wshift-negative-value]

May need suppression, I was unable to change the code to fix the error without risk to the memory alignment

Hi,

In a similar spirit to D11119, I'm not sure if this is necessarily worth pursuing. =( BSD grep (usr.bin/grep) is slowly getting better, with only a handful of known outstanding issues remaining and will hopefully be replacing GNU grep in due time.

Hello kevans91_ksu.edu,

First of all, thank you for the feedback! Due to the current status of this app, and the likelihood of replacement, what would your recommendation be for this revision moving forward, to abandon like D11119?

Thank you again,
Regards
Aaron

Hello kevans91_ksu.edu,

First of all, thank you for the feedback! Due to the current status of this app, and the likelihood of replacement, what would your recommendation be for this revision moving forward, to abandon like D11119?

Thank you again,
Regards
Aaron

I think abandonment would probably be a good idea in this case as well -- any similar interests in bsdgrep are more than welcome. =)

I don't have any ETA on the switch to bsdgrep. Since we don't, I want to clean up the code that we are actively using first.

I don't have any ETA on the switch to bsdgrep. Since we don't, I want to clean up the code that we are actively using first.

That's fair, I didn't know if it was worth it for a couple of mostly innocuous warnings in GPL bits. =)