* we expect to see. (It could be bigger, perhaps for a new version
* of the format.)
*
- * Returns the number of bytes consumed by the descriptor, or a
- * negative errno.
+ * Returns the (non-zero) number of bytes consumed by the descriptor,
+ * or a negative errno.
*/
static int identify_descriptor(struct gb_interface *intf,
struct greybus_descriptor *desc, size_t size)
return -ENOMEM;
descriptor->size = desc_size;
- descriptor->data = (u8 *)desc + sizeof(*desc_header);
+ descriptor->data = (char *)desc + sizeof(*desc_header);
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 */
+ /* desc_size is positive and is known to fit in a signed int */
return desc_size;
}
return NULL;
list_for_each_entry(descriptor, &intf->manifest_descs, links) {
-
if (descriptor->type != GREYBUS_TYPE_STRING)
continue;
return ERR_PTR(-ENOENT);
/* Allocate an extra byte so we can guarantee it's NUL-terminated */
- string = kmemdup(&desc_string->string, (size_t)desc_string->length + 1,
+ string = kmemdup(&desc_string->string, desc_string->length + 1,
GFP_KERNEL);
if (!string)
return ERR_PTR(-ENOMEM);
}
/*
- * Find cport descriptors in the manifest and set up data structures
- * for the functions that use them. Returns the number of bundles
- * set up for the given interface, or 0 if there is an error.
+ * Find cport descriptors in the manifest associated with the given
+ * bundle, and set up data structures for the functions that use
+ * them. Returns the number of cports set up for the bundle, or 0
+ * if there is an error.
*/
static u32 gb_manifest_parse_cports(struct gb_interface *intf,
struct gb_bundle *bundle)
if (IS_ERR(intf->vendor_string))
return false;
- intf->product_string = gb_string_get(intf,
- desc_intf->product_stringid);
- if (IS_ERR(intf->product_string)) {
+ intf->product_string = gb_string_get(intf, desc_intf->product_stringid);
+ if (IS_ERR(intf->product_string))
goto out_free_vendor_string;
- }
// FIXME
// Vendor, Product and Unique id must come via control protocol
}
/*
- * Parse a buffer containing a Interface manifest.
+ * Parse a buffer containing an interface manifest.
*
* If we find anything wrong with the content/format of the buffer
* we reject it.
* the descriptors it contains, keeping track for each its type
* and the location size of its data in the buffer.
*
- * Next we scan the descriptors, looking for a interface descriptor;
+ * Next we scan the descriptors, looking for an interface descriptor;
* there must be exactly one of those. When found, we record the
* information it contains, and then remove that descriptor (and any
* string descriptors it refers to) from further consideration.
return false;
/* we have to have at _least_ the manifest header */
- if (size <= sizeof(manifest->header)) {
- pr_err("short manifest (%zu)\n", size);
+ if (size < sizeof(*header)) {
+ pr_err("short manifest (%zu < %zu)\n", size, sizeof(*header));
return false;
}