[dia] [warningectomy] comparison of unsigned enum expression is always



commit a61c1b4e93b0af0bc7d16c4ece726f2f946748fe
Author: Hans Breuer <hans breuer org>
Date:   Sat Apr 5 22:06:51 2014 +0200

    [warningectomy] comparison of unsigned enum expression is always
    
    arrows.c:2050:19: warning: comparison of unsigned enum expression < 0 is always false 
[-Wtautological-compare]
      if (arrow->type < 0 || arrow->type > MAX_ARROW_TYPE) {
          ~~~~~~~~~~~ ^ ~
    arrows.c:2189:12: warning: comparison of unsigned enum expression >= 0 is always true 
[-Wtautological-compare]
      if (type >= 0 && type < MAX_ARROW_TYPE) {
          ~~~~ ^  ~
    object.c:1116:25: warning: comparison of unsigned enum expression >= 0 is always true 
[-Wtautological-compare]
            dia_assert_true((h->id >= 0 && h->id <= HANDLE_MOVE_ENDPOINT)
                             ~~~~~ ^  ~
    object.c:1121:26: warning: comparison of unsigned enum expression >= 0 is always true 
[-Wtautological-compare]
            dia_assert_true(h->type >= 0 && h->type <= NUM_HANDLE_TYPES,
                            ~~~~~~~ ^  ~
    object.c:1126:34: warning: comparison of unsigned enum expression >= 0 is always true 
[-Wtautological-compare]
            dia_assert_true(h->connect_type >= 0
                            ~~~~~~~~~~~~~~~ ^  ~

 lib/arrows.c  |    4 ++--
 lib/message.c |    2 +-
 lib/message.h |    2 +-
 lib/object.c  |    7 +++----
 4 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/lib/arrows.c b/lib/arrows.c
index 083fe46..2990893 100644
--- a/lib/arrows.c
+++ b/lib/arrows.c
@@ -2047,7 +2047,7 @@ arrow_draw(DiaRenderer *renderer, ArrowType type,
 static void
 sanitize_arrow(Arrow *arrow, DiaContext *ctx)
 {
-  if (arrow->type < 0 || arrow->type > MAX_ARROW_TYPE) {
+  if (arrow->type > MAX_ARROW_TYPE) {
     dia_context_add_message(ctx, _("Arrow head of unknown type"));
     arrow->type = ARROW_NONE;
     arrow->width = DEFAULT_ARROW_WIDTH;
@@ -2186,7 +2186,7 @@ get_arrow_names(void)
 const gchar *
 arrow_get_name_from_type(ArrowType type)
 {
-  if (type >= 0 && type < MAX_ARROW_TYPE) {
+  if (type < MAX_ARROW_TYPE) {
     return arrow_types[arrow_index_from_type(type)].name;
   }
   return _("unknown arrow");
diff --git a/lib/message.c b/lib/message.c
index b0e1737..f013188 100644
--- a/lib/message.c
+++ b/lib/message.c
@@ -152,7 +152,7 @@ message_create_dialog(const gchar *title, DiaMessageInfo *msginfo, gchar *buf)
 
 static void
 gtk_message_internal(const char* title, enum ShowAgainStyle showAgain,
-                    const char *fmt,
+                    char const *fmt,
                      va_list args, va_list args2)
 {
   static gchar *buf = NULL;
diff --git a/lib/message.h b/lib/message.h
index 4d31b37..dfb5106 100644
--- a/lib/message.h
+++ b/lib/message.h
@@ -29,7 +29,7 @@ enum ShowAgainStyle {
 };
 
 typedef void (*MessageInternal)(const char *title, enum ShowAgainStyle showAgain,
-                               const char *fmt,
+                               char const *fmt,
                                 va_list args,  va_list args2);
 
 void set_message_func(MessageInternal func);
diff --git a/lib/object.c b/lib/object.c
index c510d00..bdb3200 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -1113,18 +1113,17 @@ dia_object_sanity_check(const DiaObject *obj, const gchar *msg) {
                      msg, obj, i);
       if (h != NULL) {
        /* Check handle id */
-       dia_assert_true((h->id >= 0 && h->id <= HANDLE_MOVE_ENDPOINT)
+       dia_assert_true((h->id <= HANDLE_MOVE_ENDPOINT)
                        || (h->id >= HANDLE_CUSTOM1 && h->id <= HANDLE_CUSTOM9),
                        "%s: Object %p handle %d (%p) has wrong id %d\n", 
                        msg, obj, i, h, h->id);
        /* Check handle type */
-       dia_assert_true(h->type >= 0 && h->type <= NUM_HANDLE_TYPES,
+       dia_assert_true(h->type <= NUM_HANDLE_TYPES,
                        "%s: Object %p handle %d (%p) has wrong type %d\n", 
                        msg, obj, i, h, h->type);
        /* Check handle pos is legal pos */
        /* Check connect type is legal */
-       dia_assert_true(h->connect_type >= 0
-                       && h->connect_type <= HANDLE_CONNECTABLE_NOBREAK,
+       dia_assert_true(h->connect_type <= HANDLE_CONNECTABLE_NOBREAK,
                        "%s: Object %p handle %d (%p) has wrong connect type %d\n", 
                        msg, obj, i, h, h->connect_type);
        /* Check that if connected, connection makes sense */


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