[2/4] sunrpc: Suppress GCC -O1 warning on user2netname [BZ #19444]

Message ID 20221229125802.2715435-3-adhemerval.zanella@linaro.org
State Committed
Commit 8176efe3cabeee003f193f6b877297bf5aee8eb6
Headers
Series Fix remaining -Os/-O1 compile issues [BZ #19444] |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Adhemerval Zanella Dec. 29, 2022, 12:58 p.m. UTC
  The same issue described by 6128e82ebe973163d2dd614d31753c88c0c4d645
also happend with -O1.

Checked on x86_64-linux-gnu.
---
 sunrpc/netname.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

Carlos O'Donell Jan. 9, 2023, 5:09 p.m. UTC | #1
On 12/29/22 07:58, Adhemerval Zanella via Libc-alpha wrote:
> The same issue described by 6128e82ebe973163d2dd614d31753c88c0c4d645
> also happend with -O1.
> 
> Checked on x86_64-linux-gnu.
> ---
>  sunrpc/netname.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> 
> diff --git a/sunrpc/netname.c b/sunrpc/netname.c
> index c1d1c43e50..a10591c071 100644
> --- a/sunrpc/netname.c
> +++ b/sunrpc/netname.c
> @@ -49,10 +49,11 @@ user2netname (char netname[MAXNETNAMELEN + 1], const uid_t uid,
>    if ((strlen (dfltdom) + OPSYS_LEN + 3 + MAXIPRINT) > (size_t) MAXNETNAMELEN)
>      return 0;
>  
> -  /* GCC with -Os warns that sprint might overflow while handling dfltdom,
> -     however the above test does check if an overflow would happen.  */
> +  /* GCC with -Os or -O1 warns that sprint might overflow while handling
> +     dfltdom, however the above test does check if an overflow would
> +     happen.  */
>    DIAG_PUSH_NEEDS_COMMENT;
> -  DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wformat-overflow");
> +  DIAG_IGNORE_NEEDS_COMMENT (8, "-Wformat-overflow");
>    sprintf (netname, "%s.%d@%s", OPSYS, uid, dfltdom);
>    DIAG_POP_NEEDS_COMMENT;
>    i = strlen (netname);
  

Patch

diff --git a/sunrpc/netname.c b/sunrpc/netname.c
index c1d1c43e50..a10591c071 100644
--- a/sunrpc/netname.c
+++ b/sunrpc/netname.c
@@ -49,10 +49,11 @@  user2netname (char netname[MAXNETNAMELEN + 1], const uid_t uid,
   if ((strlen (dfltdom) + OPSYS_LEN + 3 + MAXIPRINT) > (size_t) MAXNETNAMELEN)
     return 0;
 
-  /* GCC with -Os warns that sprint might overflow while handling dfltdom,
-     however the above test does check if an overflow would happen.  */
+  /* GCC with -Os or -O1 warns that sprint might overflow while handling
+     dfltdom, however the above test does check if an overflow would
+     happen.  */
   DIAG_PUSH_NEEDS_COMMENT;
-  DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wformat-overflow");
+  DIAG_IGNORE_NEEDS_COMMENT (8, "-Wformat-overflow");
   sprintf (netname, "%s.%d@%s", OPSYS, uid, dfltdom);
   DIAG_POP_NEEDS_COMMENT;
   i = strlen (netname);