From 7fe36553d1cf57f4daacfc0359d960e4d5bc0985 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 10 Jun 2013 17:20:04 +0200 Subject: [PATCH] make size related int variables unsigned --- data/gen-code.pl | 12 ++++++------ data/gen-header.pl | 4 ++-- qmi-message.c | 12 ++++++------ qmi-message.h | 10 +++++----- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/data/gen-code.pl b/data/gen-code.pl index c903d6b..63871a0 100755 --- a/data/gen-code.pl +++ b/data/gen-code.pl @@ -83,7 +83,7 @@ sub gen_tlv_parse_field($$$$) { $data .= $indent."while($iterator\-- > 0) {\n"; } - $var_iterator and $data .= $indent."\tint i$iterator;\n"; + $var_iterator and $data .= $indent."\tunsigned int i$iterator;\n"; $data .= $var_data; $data .= $indent."}\n"; @@ -191,7 +191,7 @@ sub gen_parse_func($$) print <$type.tlv; - int tlv_len = le16_to_cpu(msg->$type.tlv_len); + unsigned int tlv_len = le16_to_cpu(msg->$type.tlv_len); EOF if (gen_has_types($data)) { @@ -310,7 +310,7 @@ sub gen_tlv_val_set($$$$$) my ($var_data, $var_iterator) = gen_tlv_val_set($cname."[$iterator]", $elem->{"array-element"}, "$indent\t", "i$iterator", undef); - $var_iterator and $data .= $indent."\tint i$iterator;\n"; + $var_iterator and $data .= $indent."\tunsigned int i$iterator;\n"; $data .= $var_data; $data .= $indent."}\n"; @@ -376,12 +376,12 @@ sub gen_tlv_attr_set($$) my $cond = "req->set.$cname"; my ($var_data, $use_iterator) = gen_tlv_val_set("req->data.$cname", $elem, "\t\t", "i", \$cond); - $use_iterator and $iterator = "\t\tint i;\n"; + $use_iterator and $iterator = "\t\tunsigned int i;\n"; $data = <data[ofs]; ofs += _size; if (ofs > cur_tlv_len) goto error_len; _buf; }) #define copy_tlv(_val, _size) \\ do { \\ - int __size = _size; \\ + unsigned int __size = _size; \\ if (__size > 0) \\ memcpy(__qmi_alloc_static(__size), _val, __size); \\ } while (0); diff --git a/data/gen-header.pl b/data/gen-header.pl index f1cc1f9..818adf1 100755 --- a/data/gen-header.pl +++ b/data/gen-header.pl @@ -45,7 +45,7 @@ sub gen_tlv_type($$$) { } my ($type, $no_set_field) = gen_tlv_type("*$cname", $elem->{"array-element"}, $indent); return undef if not defined $type; - return $indent."int $cname\_n;$type", 1; + return $indent."unsigned int $cname\_n;$type", 1; } elsif ($type eq "sequence" or $type eq "struct") { my $contents = $elem->{"contents"}; my $data = "struct {"; @@ -75,7 +75,7 @@ sub gen_tlv_struct($$) { $_data .= $data; next if $no_set_field; - $_set .= "\n\t\tint $cname : 1;"; + $_set .= "\n\t\tunsigned int $cname : 1;"; } $name = gen_cname($name); diff --git a/qmi-message.c b/qmi-message.c index 450f39c..bc16923 100644 --- a/qmi-message.c +++ b/qmi-message.c @@ -5,9 +5,9 @@ #include "qmi-message.h" static uint8_t buf[QMI_BUFFER_LEN]; -static int buf_ofs; +static unsigned int buf_ofs; -uint8_t *__qmi_get_buf(int *ofs) +uint8_t *__qmi_get_buf(unsigned int *ofs) { *ofs = buf_ofs; return buf; @@ -18,7 +18,7 @@ void __qmi_alloc_reset(void) buf_ofs = 0; } -void *__qmi_alloc_static(int len) +void *__qmi_alloc_static(unsigned int len) { void *ret; @@ -33,7 +33,7 @@ void *__qmi_alloc_static(int len) return ret; } -char *__qmi_copy_string(void *data, int len) +char *__qmi_copy_string(void *data, unsigned int len) { char *res; @@ -44,7 +44,7 @@ char *__qmi_copy_string(void *data, int len) return res; } -struct tlv *tlv_get_next(void **buf, int *buflen) +struct tlv *tlv_get_next(void **buf, unsigned int *buflen) { struct tlv *tlv = NULL; unsigned int tlv_len; @@ -108,7 +108,7 @@ int qmi_complete_request_message(struct qmi_msg *qm) return tlv_end - msg_start + 1; } -int qmi_check_message_status(void *tlv_buf, int len) +int qmi_check_message_status(void *tlv_buf, unsigned int len) { struct tlv *tlv; struct { diff --git a/qmi-message.h b/qmi-message.h index 02cd881..4ba8e5c 100644 --- a/qmi-message.h +++ b/qmi-message.h @@ -79,21 +79,21 @@ enum { #define QMI_BUFFER_LEN 2048 void __qmi_alloc_reset(void); -void *__qmi_alloc_static(int len); -char *__qmi_copy_string(void *data, int len); -uint8_t *__qmi_get_buf(int *ofs); +void *__qmi_alloc_static(unsigned int len); +char *__qmi_copy_string(void *data, unsigned int len); +uint8_t *__qmi_get_buf(unsigned int *ofs); static inline int tlv_data_len(struct tlv *tlv) { return le16_to_cpu(tlv->len); } -struct tlv *tlv_get_next(void **buf, int *buflen); +struct tlv *tlv_get_next(void **buf, unsigned int *buflen); void tlv_new(struct qmi_msg *qm, uint8_t type, uint16_t len, void *data); void qmi_init_request_message(struct qmi_msg *qm, QmiService service); int qmi_complete_request_message(struct qmi_msg *qm); -int qmi_check_message_status(void *buf, int len); +int qmi_check_message_status(void *buf, unsigned int len); void *qmi_msg_get_tlv_buf(struct qmi_msg *qm, int *len); #endif -- 2.25.1