diff options
author | Alex Elder <elder@linaro.org> | 2015-03-27 15:06:24 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <greg@kroah.com> | 2015-03-30 15:28:13 +0200 |
commit | d8187aa2241136e9fb3801e82fe8c2dfdae06802 (patch) | |
tree | c73dc31e777a8d601ec162503b8769989f27fb90 /drivers/staging/greybus/manifest.c | |
parent | 973ccfd62686a2331f43b0053de052d958f50d31 (diff) |
greybus: manifest: use size_t for a size variable
In identify_descriptor(), the variable desc_size represents the size
of a memory object. So change its type from int to size_t.
The return value for this function can be desc_size cast to int.
One can verify by inspection this will never exceed INT_MAX.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/manifest.c')
-rw-r--r-- | drivers/staging/greybus/manifest.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c index 1b9edbcd08c5..c29a0c822f23 100644 --- a/drivers/staging/greybus/manifest.c +++ b/drivers/staging/greybus/manifest.c @@ -1,8 +1,8 @@ /* * Greybus module manifest parsing * - * Copyright 2014 Google Inc. - * Copyright 2014 Linaro Ltd. + * Copyright 2014-2015 Google Inc. + * Copyright 2014-2015 Linaro Ltd. * * Released under the GPLv2 only. */ @@ -79,7 +79,7 @@ static int identify_descriptor(struct gb_interface *intf, { struct greybus_descriptor_header *desc_header = &desc->header; struct manifest_desc *descriptor; - int desc_size; + size_t desc_size; size_t expected_size; if (size < sizeof(*desc_header)) { @@ -87,8 +87,8 @@ static int identify_descriptor(struct gb_interface *intf, return -EINVAL; /* Must at least have header */ } - desc_size = (int)le16_to_cpu(desc_header->size); - if ((size_t)desc_size > size) { + desc_size = le16_to_cpu(desc_header->size); + if (desc_size > size) { pr_err("descriptor too big\n"); return -EINVAL; } @@ -119,7 +119,7 @@ static int identify_descriptor(struct gb_interface *intf, } if (desc_size < expected_size) { - pr_err("%s descriptor too small (%u < %zu)\n", + pr_err("%s descriptor too small (%zu < %zu)\n", get_descriptor_type_string(desc_header->type), desc_size, expected_size); return -EINVAL; @@ -134,6 +134,8 @@ static int identify_descriptor(struct gb_interface *intf, descriptor->type = desc_header->type; list_add_tail(&descriptor->links, &intf->manifest_descs); + /* desc_size is is positive and is known to fit in a signed int */ + return desc_size; } |