public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH 1/2] Update gcc warning checks to work with gcc-4.9
@ 2014-09-12 15:47 Michał Górny
  2014-09-12 15:47 ` [gentoo-portage-dev] [PATCH 2/2] Use a single grep call for gcc warning checks Michał Górny
  2014-09-14 16:53 ` [gentoo-portage-dev] [PATCH 1/2] Update gcc warning checks to work with gcc-4.9 Zac Medico
  0 siblings, 2 replies; 5+ messages in thread
From: Michał Górny @ 2014-09-12 15:47 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

Use -W indicators whenever possible, or more flexible regular
expressions so that our checks correctly match output with
-fdiagnostics-color in gcc 4.9. Also, enable a few extra warnings that
are triggered by -W flags we already use and clean up some outdated
matches.

The check is confirmed to work correctly with gcc branches 4.7 up to
4.9.

Suggested-by: Ryan Hill <rhill@gentoo.org>
Fixes: https://bugs.gentoo.org/show_bug.cgi?id=508364
---

(both patches are based off install-qa-refactor branch)

 bin/install-qa-check.d/90gcc-warnings | 82 +++++++++++++++++++++--------------
 1 file changed, 49 insertions(+), 33 deletions(-)

diff --git a/bin/install-qa-check.d/90gcc-warnings b/bin/install-qa-check.d/90gcc-warnings
index ae39485..812bf41 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -13,44 +13,60 @@ gcc_warn_check() {
 			reset_debug=1
 		fi
 		local m msgs=(
-			": warning: dereferencing type-punned pointer will break strict-aliasing rules"
-			": warning: dereferencing pointer .* does break strict-aliasing rules"
-			": warning: implicit declaration of function"
-			": warning: incompatible implicit declaration of built-in function"
-			": warning: is used uninitialized in this function" # we'll ignore "may" and "might"
-			": warning: comparisons like X<=Y<=Z do not have their mathematical meaning"
-			": warning: null argument where non-null required"
-			": warning: array subscript is below array bounds"
-			": warning: array subscript is above array bounds"
-			": warning: attempt to free a non-heap object"
-			": warning: .* called with .*bigger.* than .* destination buffer"
-			": warning: call to .* will always overflow destination buffer"
-			": warning: assuming pointer wraparound does not occur when comparing"
-			": warning: hex escape sequence out of range"
-			": warning: [^ ]*-hand operand of comma .*has no effect"
-			": warning: converting to non-pointer type .* from NULL"
-			": warning: NULL used in arithmetic"
-			": warning: passing NULL to non-pointer argument"
-			": warning: the address of [^ ]* will always evaluate as"
-			": warning: the address of [^ ]* will never be NULL"
-			": warning: too few arguments for format"
-			": warning: reference to local variable .* returned"
-			": warning: returning reference to temporary"
-			": warning: function returns address of local variable"
-			": warning: .*\\[-Wsizeof-pointer-memaccess\\]"
-			": warning: .*\\[-Waggressive-loop-optimizations\\]"
+			# only will, no might :)
+			'warning: .*will.*\[-Wstrict-aliasing\]'
+			# implicit declaration of function ‘...’
+			'warning: .*\[-Wimplicit-function-declaration\]'
+			# with -Wall, goes in pair with -Wimplicit-function-declaration
+			# but without -Wall, we need to assert for it alone
+			'warning: .*incompatible implicit declaration of built-in function'
+			# 'is used uninitialized in this function' and some more
+			'warning: .*\[-Wuninitialized\]'
+			# comparisons like ‘X<=Y<=Z’ do not have their mathematical meaning
+			'warning: .*mathematical meaning*\[-Wparentheses\]'
+			# null argument where non-null required
+			'warning: .*\[-Wnonnull\]'
+			# array subscript is above/below/outside array bounds
+			'warning: .*\[-Warray-bounds\]'
+			# attempt to free a non-heap object
+			'warning: .*\[-Wfree-nonheap-object\]'
+			# those three do not have matching -W flags, it seems
+			'warning: .*will always overflow destination buffer'
+			'warning: .*assuming pointer wraparound does not occur'
+			'warning: .*escape sequence out of range'
+			# left/right-hand operand of comma expression has no effect
+			'warning: .*comma.*\[-Wunused-value\]'
+			# converting to non-pointer type ... from NULL and likes
+			'warning: .*\[-Wconversion-null\]'
+			# NULL used in arithmetic
+			'warning: .*NULL.*\[-Wpointer-arith\]'
+			# pointer to a function used in arithmetic and likes
+			'warning: .*function.*\[-Wpointer-arith\]'
+			# the address of ... will never be NULL and likes
+			# (uses of function refs & string constants in conditionals)
+			'warning: .*\[-Waddress\]'
+			# format ... expects a matching ... argument
+			# (iow, too few arguments for format in new wording :))
+			'warning: .*matching.*\[-Wformat=\]'
+			# function returns address of local variable
+			'warning: .*\[-Wreturn-local-addr\]'
+			# argument to sizeof ... is the same expression as the source
+			'warning: .*\[-Wsizeof-pointer-memaccess\]'
+			# iteration invokes undefined behavior
+			'warning: .*\[-Waggressive-loop-optimizations\]'
+
 			# this may be valid code :/
-			#": warning: multi-character character constant"
+			#': warning: multi-character character constant'
 			# need to check these two ...
-			#": warning: assuming signed overflow does not occur when"
-			#": warning: comparison with string literal results in unspecified behav"
+			#': warning: assuming signed overflow does not occur when'
+			#': warning: comparison with string literal results in unspecified behav'
 			# yacc/lex likes to trigger this one
-			#": warning: extra tokens at end of .* directive"
+			#': warning: extra tokens at end of .* directive'
 			# only gcc itself triggers this ?
-			#": warning: .*noreturn.* function does return"
+			#': warning: .*noreturn.* function does return'
 			# these throw false positives when 0 is used instead of NULL
-			#": warning: missing sentinel in function call"
-			#": warning: not enough variable arguments to fit a sentinel"
+			#': warning: missing sentinel in function call'
+			#': warning: not enough variable arguments to fit a sentinel'
 		)
 		local abort="no"
 		local i=0
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-portage-dev] [PATCH 2/2] Use a single grep call for gcc warning checks
  2014-09-12 15:47 [gentoo-portage-dev] [PATCH 1/2] Update gcc warning checks to work with gcc-4.9 Michał Górny
@ 2014-09-12 15:47 ` Michał Górny
  2014-09-14 16:56   ` Zac Medico
  2014-09-26 19:07   ` Brian Dolbec
  2014-09-14 16:53 ` [gentoo-portage-dev] [PATCH 1/2] Update gcc warning checks to work with gcc-4.9 Zac Medico
  1 sibling, 2 replies; 5+ messages in thread
From: Michał Górny @ 2014-09-12 15:47 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

Use a single grep call with all gcc warning checks combined rather than
calling grep separately for each message being checked. Aside to being
faster, this also avoids outputting warnings in separate blocks.
---
 bin/install-qa-check.d/90gcc-warnings | 62 +++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 29 deletions(-)

diff --git a/bin/install-qa-check.d/90gcc-warnings b/bin/install-qa-check.d/90gcc-warnings
index 812bf41..ad38754 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -68,39 +68,43 @@ gcc_warn_check() {
 			#': warning: missing sentinel in function call'
 			#': warning: not enough variable arguments to fit a sentinel'
 		)
+
+		# join all messages into one grep-expression
+		local joined_msgs
+		printf -v joined_msgs '%s|' "${msgs[@]}"
+		joined_msgs=${joined_msgs%|}
+
 		local abort="no"
-		local i=0
 		local grep_cmd=grep
 		[[ $PORTAGE_LOG_FILE = *.gz ]] && grep_cmd=zgrep
-		while [[ -n ${msgs[${i}]} ]] ; do
-			m=${msgs[$((i++))]}
-			# force C locale to work around slow unicode locales #160234
-			f=$(LC_ALL=C $grep_cmd "${m}" "${PORTAGE_LOG_FILE}")
-			if [[ -n ${f} ]] ; then
-				abort="yes"
-				# for now, don't make this fatal (see bug #337031)
-				#case "$m" in
-				#	": warning: call to .* will always overflow destination buffer") always_overflow=yes ;;
-				#esac
-				if [[ $always_overflow = yes ]] ; then
-					eerror
-					eerror "QA Notice: Package triggers severe warnings which indicate that it"
-					eerror "           may exhibit random runtime failures."
-					eerror
-					eerror "${f}"
-					eerror
-					eerror " Please file a bug about this at http://bugs.gentoo.org/"
-					eerror " with the maintaining herd of the package."
-					eerror
-				else
-					__vecho -ne '\n'
-					eqawarn "QA Notice: Package triggers severe warnings which indicate that it"
-					eqawarn "           may exhibit random runtime failures."
-					eqawarn "${f}"
-					__vecho -ne '\n'
-				fi
+
+		# force C locale to work around slow unicode locales #160234
+		f=$(LC_CTYPE=C LC_COLLATE=C "${grep_cmd}" -E "${joined_msgs}" "${PORTAGE_LOG_FILE}")
+		if [[ -n ${f} ]] ; then
+			abort="yes"
+			# for now, don't make this fatal (see bug #337031)
+			#if [[ ${f} == *'will always overflow destination buffer'* ]]; then
+			#	always_overflow=yes
+			#fi
+			if [[ $always_overflow = yes ]] ; then
+				eerror
+				eerror "QA Notice: Package triggers severe warnings which indicate that it"
+				eerror "           may exhibit random runtime failures."
+				eerror
+				eerror "${f}"
+				eerror
+				eerror " Please file a bug about this at http://bugs.gentoo.org/"
+				eerror " with the maintaining herd of the package."
+				eerror
+			else
+				__vecho -ne '\n'
+				eqawarn "QA Notice: Package triggers severe warnings which indicate that it"
+				eqawarn "           may exhibit random runtime failures."
+				eqawarn "${f}"
+				__vecho -ne '\n'
 			fi
-		done
+		fi
+
 		local cat_cmd=cat
 		[[ $PORTAGE_LOG_FILE = *.gz ]] && cat_cmd=zcat
 		[[ $reset_debug = 1 ]] && set -x
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [gentoo-portage-dev] [PATCH 1/2] Update gcc warning checks to work with gcc-4.9
  2014-09-12 15:47 [gentoo-portage-dev] [PATCH 1/2] Update gcc warning checks to work with gcc-4.9 Michał Górny
  2014-09-12 15:47 ` [gentoo-portage-dev] [PATCH 2/2] Use a single grep call for gcc warning checks Michał Górny
@ 2014-09-14 16:53 ` Zac Medico
  1 sibling, 0 replies; 5+ messages in thread
From: Zac Medico @ 2014-09-14 16:53 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

On 09/12/2014 08:47 AM, Michał Górny wrote:
> Use -W indicators whenever possible, or more flexible regular
> expressions so that our checks correctly match output with
> -fdiagnostics-color in gcc 4.9. Also, enable a few extra warnings that
> are triggered by -W flags we already use and clean up some outdated
> matches.
> 
> The check is confirmed to work correctly with gcc branches 4.7 up to
> 4.9.
> 
> Suggested-by: Ryan Hill <rhill@gentoo.org>
> Fixes: https://bugs.gentoo.org/show_bug.cgi?id=508364
> ---
> 
> (both patches are based off install-qa-refactor branch)
> 
>  bin/install-qa-check.d/90gcc-warnings | 82 +++++++++++++++++++++--------------
>  1 file changed, 49 insertions(+), 33 deletions(-)

LGTM.
-- 
Thanks,
Zac


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-portage-dev] [PATCH 2/2] Use a single grep call for gcc warning checks
  2014-09-12 15:47 ` [gentoo-portage-dev] [PATCH 2/2] Use a single grep call for gcc warning checks Michał Górny
@ 2014-09-14 16:56   ` Zac Medico
  2014-09-26 19:07   ` Brian Dolbec
  1 sibling, 0 replies; 5+ messages in thread
From: Zac Medico @ 2014-09-14 16:56 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

On 09/12/2014 08:47 AM, Michał Górny wrote:
> Use a single grep call with all gcc warning checks combined rather than
> calling grep separately for each message being checked. Aside to being
> faster, this also avoids outputting warnings in separate blocks.
> ---
>  bin/install-qa-check.d/90gcc-warnings | 62 +++++++++++++++++++----------------
>  1 file changed, 33 insertions(+), 29 deletions(-)

LGTM.
-- 
Thanks,
Zac


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-portage-dev] [PATCH 2/2] Use a single grep call for gcc warning checks
  2014-09-12 15:47 ` [gentoo-portage-dev] [PATCH 2/2] Use a single grep call for gcc warning checks Michał Górny
  2014-09-14 16:56   ` Zac Medico
@ 2014-09-26 19:07   ` Brian Dolbec
  1 sibling, 0 replies; 5+ messages in thread
From: Brian Dolbec @ 2014-09-26 19:07 UTC (permalink / raw
  To: gentoo-portage-dev

On Fri, 12 Sep 2014 17:47:43 +0200
Michał Górny <mgorny@gentoo.org> wrote:

> Use a single grep call with all gcc warning checks combined rather
> than calling grep separately for each message being checked. Aside to
> being faster, this also avoids outputting warnings in separate blocks.
> ---
>  bin/install-qa-check.d/90gcc-warnings | 62
> +++++++++++++++++++---------------- 1 file changed, 33 insertions(+),
> 

Merged Both patches, 1 & 2 of 2, released in 2.2.14_rc1

-- 
Brian Dolbec <dolsen>



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-26 19:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-12 15:47 [gentoo-portage-dev] [PATCH 1/2] Update gcc warning checks to work with gcc-4.9 Michał Górny
2014-09-12 15:47 ` [gentoo-portage-dev] [PATCH 2/2] Use a single grep call for gcc warning checks Michał Górny
2014-09-14 16:56   ` Zac Medico
2014-09-26 19:07   ` Brian Dolbec
2014-09-14 16:53 ` [gentoo-portage-dev] [PATCH 1/2] Update gcc warning checks to work with gcc-4.9 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox