Change from int32_t to size_t, because
    - Length is a measurement of unsigned "size".
    - In general, length values are often used in subsequent calculation
      of memory size which is passed to functions like malloc, whose
      input is size_t not int.
    - The cast from ptrdiff_t to int32_t in wcore_attrib_list_length
      just looked wrong. A cast to size_t makes more sense.

As precedent, strlen() also returns size_t.

Signed-off-by: Chad Versace <[email protected]>
---
 src/waffle/core/wcore_attrib_list.c | 4 ++--
 src/waffle/core/wcore_attrib_list.h | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/waffle/core/wcore_attrib_list.c 
b/src/waffle/core/wcore_attrib_list.c
index 09a4dec..b80f5cf 100644
--- a/src/waffle/core/wcore_attrib_list.c
+++ b/src/waffle/core/wcore_attrib_list.c
@@ -29,7 +29,7 @@
 #include <stdint.h>
 #include <stddef.h>
 
-int32_t
+size_t
 wcore_attrib_list32_length(const int32_t attrib_list[])
 {
     const int32_t *i = attrib_list;
@@ -40,7 +40,7 @@ wcore_attrib_list32_length(const int32_t attrib_list[])
     while (*i != 0)
         i += 2;
 
-    return (int32_t) (i - attrib_list) / 2;
+    return (i - attrib_list) / 2;
 }
 
 bool
diff --git a/src/waffle/core/wcore_attrib_list.h 
b/src/waffle/core/wcore_attrib_list.h
index 8339578..15bd8ba 100644
--- a/src/waffle/core/wcore_attrib_list.h
+++ b/src/waffle/core/wcore_attrib_list.h
@@ -26,9 +26,10 @@
 #pragma once
 
 #include <stdbool.h>
+#include <stddef.h>
 #include <stdint.h>
 
-int32_t
+size_t
 wcore_attrib_list32_length(const int32_t attrib_list[]);
 
 bool
-- 
2.2.0

_______________________________________________
waffle mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/waffle

Reply via email to