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

[Minios-devel] [UNIKRAFT/LWIP PATCH] Fix compilation warning about comparison between signed and unsigned integer



Without this patch, compiler(gcc version 7.4.0) reports:
proto.c: In function ‘getprotoent’:
proto.c:85:10: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare]
  if (idx >= sizeof(protos))
          ^~

Signed-off-by: Jia He <justin.he@xxxxxxx>
---
 proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/proto.c b/proto.c
index 517f258..7d32bc6 100644
--- a/proto.c
+++ b/proto.c
@@ -82,7 +82,7 @@ struct protoent *getprotoent(void)
        static struct protoent p;
        static const char *aliases;
 
-       if (idx >= sizeof(protos))
+       if ((unsigned int)idx >= sizeof(protos))
                return NULL;
        p.p_proto = protos[idx];
        p.p_name = (char *)&protos[idx+1];
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.