Skip to contentSkip to conversation

pc-bios/s390-ccw: size_t should be unsigned

PATCH In review Thomas Huth 5 participants 6 messages Apr 16, 2018 – Apr 23, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pc-bios/s390-ccw: size_t should be unsigned

"size_t" should be an unsigned type according to the C standard. Thus we should also use this convention in the s390-ccw firmware to avoid confusion. I checked the sources, and apart from one spot in libc.c, the code should all be fine with this change.

---
v2: Use long instead of ssize_t in uitoa()

 pc-bios/s390-ccw/libc.c | 2 +-
 pc-bios/s390-ccw/libc.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/libc.c +1 -1
index 38ea77d..a786566 100644
@@ -63,7 +63,7 @@ uint64_t atoui(const char *str)
  */
 char *uitoa(uint64_t num, char *str, size_t len)
 {
-    size_t num_idx = 1; /* account for NUL */
+    long num_idx = 1; /* account for NUL */
     uint64_t tmp = num;
 
     IPL_assert(str != NULL, "uitoa: no space allocated to store string");
pc-bios/s390-ccw/libc.h +1 -1
index 63ece70..818517f 100644
@@ -12,7 +12,7 @@
 #ifndef S390_CCW_LIBC_H
 #define S390_CCW_LIBC_H
 
-typedef long               size_t;
+typedef unsigned long      size_t;
 typedef int                bool;
 typedef unsigned char      uint8_t;
 typedef unsigned short     uint16_t;
Signature · 1 line
1.8.3.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Thomas Huth

"size_t" should be an unsigned type according to the C standard. Thus we should also use this convention in the s390-ccw firmware to avoid confusion. I checked the sources, and apart from one spot in libc.c, the code should all be fine with this change.

looks better. I checked all users of size_t and this seems complete.

Quoted 34 lines

---
v2: Use long instead of ssize_t in uitoa()

 pc-bios/s390-ccw/libc.c | 2 +-
 pc-bios/s390-ccw/libc.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/libc.c +1 -1
index 38ea77d..a786566 100644
@@ -63,7 +63,7 @@ uint64_t atoui(const char *str)
  */
 char *uitoa(uint64_t num, char *str, size_t len)
 {
-    size_t num_idx = 1; /* account for NUL */
+    long num_idx = 1; /* account for NUL */
     uint64_t tmp = num;
 
     IPL_assert(str != NULL, "uitoa: no space allocated to store string");
pc-bios/s390-ccw/libc.h +1 -1
index 63ece70..818517f 100644
@@ -12,7 +12,7 @@
 #ifndef S390_CCW_LIBC_H
 #define S390_CCW_LIBC_H
 
-typedef long               size_t;
+typedef unsigned long      size_t;
 typedef int                bool;
 typedef unsigned char      uint8_t;
 typedef unsigned short     uint16_t;
Reviewed-by on v2 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 7 lines · Thomas Huth

"size_t" should be an unsigned type according to the C standard. Thus we should also use this convention in the s390-ccw firmware to avoid confusion. I checked the sources, and apart from one spot in libc.c, the code should all be fine with this change.

Reviewed-by on v2 1/1
#3 lore raw
In reply to Thomas Huth
Quoted 33 lines · Thomas Huth

"size_t" should be an unsigned type according to the C standard. Thus we should also use this convention in the s390-ccw firmware to avoid confusion. I checked the sources, and apart from one spot in libc.c, the code should all be fine with this change.

---
v2: Use long instead of ssize_t in uitoa()

 pc-bios/s390-ccw/libc.c | 2 +-
 pc-bios/s390-ccw/libc.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/libc.c +1 -1
index 38ea77d..a786566 100644
@@ -63,7 +63,7 @@ uint64_t atoui(const char *str)
  */
 char *uitoa(uint64_t num, char *str, size_t len)
 {
-    size_t num_idx = 1; /* account for NUL */
+    long num_idx = 1; /* account for NUL */
     uint64_t tmp = num;
 
     IPL_assert(str != NULL, "uitoa: no space allocated to store string");
pc-bios/s390-ccw/libc.h +0 -0
index 63ece70..818517f 100644

pc-bios/s390-ccw/libc.h line 18

Quoted 8 lines
pc-bios/s390-ccw/libc.h +1 -1
@@ -12,7 +12,7 @@
 #ifndef S390_CCW_LIBC_H
 #define S390_CCW_LIBC_H
 
-typedef long               size_t;
+typedef unsigned long      size_t;
 typedef int                bool;
 typedef unsigned char      uint8_t;
 typedef unsigned short     uint16_t;
Signature · 2 lines
Respectfully,
- Collin Walling
Reviewed-by on v2 1/1
#4 lore raw
In reply to Thomas Huth
Quoted 5 lines · On Mon, 16 Apr 2018 09:45:20 +0200 Thomas Huth <[email protected]> wrote:

"size_t" should be an unsigned type according to the C standard. Thus we should also use this convention in the s390-ccw firmware to avoid confusion. I checked the sources, and apart from one spot in libc.c, the code should all be fine with this change.

Quoted 8 lines

---
v2: Use long instead of ssize_t in uitoa()

 pc-bios/s390-ccw/libc.c | 2 +-
 pc-bios/s390-ccw/libc.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

I assume you'll queue this one yourself?

#5 lore raw
Quoted 13 lines · Cornelia Huck
Quoted 10 lines · On Mon, 16 Apr 2018 09:45:20 +0200 Thomas Huth <[email protected]> wrote:

"size_t" should be an unsigned type according to the C standard. Thus we should also use this convention in the s390-ccw firmware to avoid confusion. I checked the sources, and apart from one spot in libc.c, the code should all be fine with this change.

---
v2: Use long instead of ssize_t in uitoa()

Quoted 7 lines
Quoted 3 lines
 pc-bios/s390-ccw/libc.c | 2 +-
 pc-bios/s390-ccw/libc.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

I assume you'll queue this one yourself?

Yes, I'll queue it with the other pending s390-ccw bios patches.

Thomas