tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Limiting -Wno-error=format-truncation to specific GCC version



On Fri, 26 Oct 2018 at 19:08, David Brownlee <abs%absd.org@localhost> wrote:
>
> What would be the best way to limit the following to gcc8 or above? (its not needed in gcc7, 6 or 5 for acpica-utils and I'm assuming there is a version of GCC earlier enough in use that doesn't support it)
>
> .if !empty(PKGSRC_COMPILER:Mgcc)
> CFLAGS+=        -Wno-error=format-truncation
> .endif
>
> (Background: compiling acpica-utils under gcc8 errored out with a potential sprintf overflow. Patching to use snprintf as below lead to an error as its built with -Werror)
>
> -            sprintf (MsgBuffer, "%s required for %4.4s",
> +            snprintf (MsgBuffer, sizeof(MsgBuffer), "%s required for %4.4s",
>                  StringBuffer, ThisName->Info.Name);
>
> Alternatively, so I just throw -Wno-error at it or something else :)
>

For reference, in the end went with:

.if !empty(CC_VERSION:Mgcc-8*)
CFLAGS+=        -Wno-error=format-truncation
.endif

David


Home | Main Index | Thread Index | Old Index