bug-hurd
[Top][All Lists]
Advanced

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

Re: [PATCH mig] Suffix complex_alignof with U to hint the compiler that


From: Almudena Garcia
Subject: Re: [PATCH mig] Suffix complex_alignof with U to hint the compiler that it is always unsigned
Date: Thu, 18 Jul 2024 23:40:53 +0200

do this means that you are updating rumpkernel sources? I tried to update rumpdisk sources some months ago, but i had problems with the Hurd patches.

El jue, 18 jul 2024 a las 23:25, Flavio Cruz (<flaviocruz@gmail.com>) escribió:
I have noticed a problem when compiling rumpkernel with the new
thread_get_name:

gnumachUser.c: In function 'thread_get_name':
gnumachUser.c:1791:37: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
 1791 |         if (mig_unlikely (msgh_size != 36 + ((OutP->nameType.msgt_number + 3) & ~3)))
      |                                     ^~
gnumachUser.c:25:47: note: in definition of macro 'mig_unlikely'
   25 | #define mig_unlikely(X) __builtin_expect (!! (X), 0)
      |                                               ^
cc1: all warnings being treated as errors

This ensures that the compiler won't cast ~3 to int since the code will
be written as:

 1791 |         if (mig_unlikely (msgh_size != 36 + ((OutP->nameType.msgt_number + 3) & ~3U)))
---
 server.c | 4 ++--
 user.c   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/server.c b/server.c
index e02e1e7..8da231c 100644
--- a/server.c
+++ b/server.c
@@ -511,7 +511,7 @@ WriteCheckArgSize(FILE *file, const argument_t *arg)
     /* If the base type size of the data field isn`t a multiple of complex_alignof,
        we have to round up. */
     if (btype->itTypeSize % complex_alignof != 0)
-       fprintf(file, " + %zd) & ~%zd", complex_alignof - 1, complex_alignof - 1);
+       fprintf(file, " + %zd) & ~%zdU", complex_alignof - 1, complex_alignof - 1);

     if (ptype->itIndefinite) {
        fprintf(file, " : sizeof(%s *)", FetchServerType(btype));
@@ -1192,7 +1192,7 @@ WriteArgSize(FILE *file, const argument_t *arg)
      * we have to round up.
      */
     if (bsize % complex_alignof != 0)
-       fprintf(file, " + %zd) & ~%zd", complex_alignof - 1, complex_alignof - 1);
+       fprintf(file, " + %zd) & ~%zdU", complex_alignof - 1, complex_alignof - 1);

     if (ptype->itIndefinite) {
        fprintf(file, " : sizeof(%s *)",
diff --git a/user.c b/user.c
index d98ab98..48b8c8b 100644
--- a/user.c
+++ b/user.c
@@ -552,7 +552,7 @@ WriteArgSize(FILE *file, const argument_t *arg)
      * we have to round up.
      */
     if (bsize % complex_alignof != 0)
-       fprintf(file, " + %zd) & ~%zd", complex_alignof - 1, complex_alignof - 1);
+       fprintf(file, " + %zd) & ~%zdU", complex_alignof - 1, complex_alignof - 1);

     if (ptype->itIndefinite) {
        fprintf(file, " : sizeof(%s *)",
@@ -880,7 +880,7 @@ WriteCheckArgSize(FILE *file, const argument_t *arg)
     /* If the base type size of the data field isn`t a multiple of complex_alignof,
        we have to round up. */
     if (btype->itTypeSize % complex_alignof != 0)
-       fprintf(file, " + %zd) & ~%zd", complex_alignof - 1, complex_alignof - 1);
+       fprintf(file, " + %zd) & ~%zdU", complex_alignof - 1, complex_alignof - 1);

     if (ptype->itIndefinite)
        fprintf(file, " : sizeof(%s *)", FetchUserType(btype));
--
2.43.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]