Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1447680 > unrolled thread

[PATCH] libata: add parentheses to avoid a gcc warning

Started byArnd Bergmann <arnd@arndb.de>
First post2016-07-21 09:50 +0200
Last post2016-07-21 11:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] libata: add parentheses to avoid a gcc warning Arnd Bergmann <arnd@arndb.de> - 2016-07-21 09:50 +0200
    Re: [PATCH] libata: add parentheses to avoid a gcc warning Tom Yan <tom.ty89@gmail.com> - 2016-07-21 11:50 +0200

#1447680 — [PATCH] libata: add parentheses to avoid a gcc warning

FromArnd Bergmann <arnd@arndb.de>
Date2016-07-21 09:50 +0200
Subject[PATCH] libata: add parentheses to avoid a gcc warning
Message-ID<rXgU1-4ur-15@gated-at.bofh.it>
gcc-6.1 warns about possibly ambiguous code that was newly added
to libata:

drivers/ata/libata-scsi.c: In function 'ata_mselect_caching':
drivers/ata/libata-scsi.c:3637:28: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
drivers/ata/libata-scsi.c: In function 'ata_mselect_control':
drivers/ata/libata-scsi.c:3702:28: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]

The code is fine, and it's not really ambigous to human readers,
but let's shut up the warning anyway by adding the parentheses
that gcc suggests.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 9b7844a8c34a ("libata-scsi: fix read-only bits checking in ata_mselect_*()")
---
 drivers/ata/libata-scsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index fa9d16fe295c..8ad4b237f342 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3634,7 +3634,7 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc,
 		/* Check the first byte */
 		if (i == 0) {
 			/* except the WCE bit */
-			if (mpage[i + 2] & 0xfb != buf[i] & 0xfb) {
+			if ((mpage[i + 2] & 0xfb) != (buf[i] & 0xfb)) {
 				*fp = i;
 				return -EINVAL;
 			} else {
@@ -3699,7 +3699,7 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
 		/* Check the first byte */
 		if (i == 0) {
 			/* except the D_SENSE bit */
-			if (mpage[i + 2] & 0xfb != buf[i] & 0xfb) {
+			if ((mpage[i + 2] & 0xfb) != (buf[i] & 0xfb)) {
 				*fp = i;
 				return -EINVAL;
 			} else {
-- 
2.9.0

[toc] | [next] | [standalone]


#1447756

FromTom Yan <tom.ty89@gmail.com>
Date2016-07-21 11:50 +0200
Message-ID<rXiMa-5GH-29@gated-at.bofh.it>
In reply to#1447680
The commit has been reverted. The parentheses are actually necessary
since `!=` is of higher precedence than `&`. My bad.

On 21 July 2016 at 15:40, Arnd Bergmann <arnd@arndb.de> wrote:
> gcc-6.1 warns about possibly ambiguous code that was newly added
> to libata:
>
> drivers/ata/libata-scsi.c: In function 'ata_mselect_caching':
> drivers/ata/libata-scsi.c:3637:28: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
> drivers/ata/libata-scsi.c: In function 'ata_mselect_control':
> drivers/ata/libata-scsi.c:3702:28: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
>
> The code is fine, and it's not really ambigous to human readers,
> but let's shut up the warning anyway by adding the parentheses
> that gcc suggests.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 9b7844a8c34a ("libata-scsi: fix read-only bits checking in ata_mselect_*()")
> ---
>  drivers/ata/libata-scsi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index fa9d16fe295c..8ad4b237f342 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3634,7 +3634,7 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc,
>                 /* Check the first byte */
>                 if (i == 0) {
>                         /* except the WCE bit */
> -                       if (mpage[i + 2] & 0xfb != buf[i] & 0xfb) {
> +                       if ((mpage[i + 2] & 0xfb) != (buf[i] & 0xfb)) {
>                                 *fp = i;
>                                 return -EINVAL;
>                         } else {
> @@ -3699,7 +3699,7 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
>                 /* Check the first byte */
>                 if (i == 0) {
>                         /* except the D_SENSE bit */
> -                       if (mpage[i + 2] & 0xfb != buf[i] & 0xfb) {
> +                       if ((mpage[i + 2] & 0xfb) != (buf[i] & 0xfb)) {
>                                 *fp = i;
>                                 return -EINVAL;
>                         } else {
> --
> 2.9.0
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web