greybus: firmware: s/_LEN/_SIZE

Alex Elder pointed out that the macros also count the trailing NULL
('\0') character and so it should be using SIZE instead of LEN.

This patch makes that change.

Reported-by: Alex Elder <alex.elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Viresh Kumar 2016-08-11 13:27:23 -07:00 committed by Greg Kroah-Hartman
parent 769cb83704
commit b2abeaa10d
7 changed files with 30 additions and 30 deletions

View File

@ -104,20 +104,20 @@ Following are the IOCTLs and their data structures available to the user:
struct fw_mgmt_ioc_get_intf_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u16 major;
__u16 minor;
} __attribute__ ((__packed__));
struct fw_mgmt_ioc_get_backend_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u16 major;
__u16 minor;
__u8 status;
} __attribute__ ((__packed__));
struct fw_mgmt_ioc_intf_load_and_validate {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
__u8 load_method;
__u8 status;
__u16 major;
@ -125,7 +125,7 @@ struct fw_mgmt_ioc_intf_load_and_validate {
} __packed;
struct fw_mgmt_ioc_backend_fw_update {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
__u8 status;
} __packed;

View File

@ -108,7 +108,7 @@ static int update_intf_firmware(int fd)
intf_load.minor = 0;
strncpy((char *)&intf_load.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_LEN);
GB_FIRMWARE_U_TAG_MAX_SIZE);
ret = ioctl(fd, FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE, &intf_load);
if (ret < 0) {
@ -146,7 +146,7 @@ static int update_backend_firmware(int fd)
printf("Getting Backend Firmware Version\n");
strncpy((char *)&backend_fw_info.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_LEN);
GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_version:
ret = ioctl(fd, FW_MGMT_IOC_GET_BACKEND_FW, &backend_fw_info);
@ -174,7 +174,7 @@ static int update_backend_firmware(int fd)
printf("Updating Backend Firmware\n");
strncpy((char *)&backend_update.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_LEN);
GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_update:
backend_update.status = 0;

View File

@ -15,7 +15,7 @@
#define FW_NAME_PREFIX "gmp_"
/* Length of the string in format: "FW_NAME_PREFIX""%08x_%08x_%08x_%08x_%s.tftf" */
#define FW_NAME_LEN 56
#define FW_NAME_SIZE 56
/* Firmware Management Protocol specific functions */
int fw_mgmt_init(void);

View File

@ -23,7 +23,7 @@ struct fw_request {
u8 firmware_id;
bool disabled;
bool timedout;
char name[FW_NAME_LEN];
char name[FW_NAME_SIZE];
const struct firmware *fw;
struct list_head node;
@ -239,7 +239,7 @@ static int fw_download_find_firmware(struct gb_operation *op)
tag = (const char *)request->firmware_tag;
/* firmware_tag should be null-terminated */
if (strnlen(tag, GB_FIRMWARE_TAG_MAX_LEN) == GB_FIRMWARE_TAG_MAX_LEN) {
if (strnlen(tag, GB_FIRMWARE_TAG_MAX_SIZE) == GB_FIRMWARE_TAG_MAX_SIZE) {
dev_err(fw_download->parent,
"firmware-tag is not null-terminated\n");
return -EINVAL;

View File

@ -122,16 +122,16 @@ static int fw_mgmt_interface_fw_version_operation(struct fw_mgmt *fw_mgmt,
fw_info->minor = le16_to_cpu(response.minor);
strncpy(fw_info->firmware_tag, response.firmware_tag,
GB_FIRMWARE_TAG_MAX_LEN);
GB_FIRMWARE_TAG_MAX_SIZE);
/*
* The firmware-tag should be NULL terminated, otherwise throw error but
* don't fail.
*/
if (fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') {
if (fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
dev_err(fw_mgmt->parent,
"fw-version: firmware-tag is not NULL terminated\n");
fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] = '\0';
fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] = '\0';
}
return 0;
@ -151,13 +151,13 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt,
}
request.load_method = load_method;
strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_LEN);
strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE);
/*
* The firmware-tag should be NULL terminated, otherwise throw error and
* fail.
*/
if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') {
if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is not NULL terminated\n");
return -EINVAL;
}
@ -249,13 +249,13 @@ static int fw_mgmt_backend_fw_version_operation(struct fw_mgmt *fw_mgmt,
int ret;
strncpy(request.firmware_tag, fw_info->firmware_tag,
GB_FIRMWARE_TAG_MAX_LEN);
GB_FIRMWARE_TAG_MAX_SIZE);
/*
* The firmware-tag should be NULL terminated, otherwise throw error and
* fail.
*/
if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') {
if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
dev_err(fw_mgmt->parent, "backend-version: firmware-tag is not NULL terminated\n");
return -EINVAL;
}
@ -302,13 +302,13 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt,
struct gb_fw_mgmt_backend_fw_update_request request;
int ret;
strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_LEN);
strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE);
/*
* The firmware-tag should be NULL terminated, otherwise throw error and
* fail.
*/
if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') {
if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
dev_err(fw_mgmt->parent, "backend-update: firmware-tag is not NULL terminated\n");
return -EINVAL;
}

View File

@ -57,7 +57,7 @@
#include <linux/ioctl.h>
#include <linux/types.h>
#define GB_FIRMWARE_U_TAG_MAX_LEN 10
#define GB_FIRMWARE_U_TAG_MAX_SIZE 10
#define GB_FW_U_LOAD_METHOD_UNIPRO 0x01
#define GB_FW_U_LOAD_METHOD_INTERNAL 0x02
@ -83,20 +83,20 @@
/* IOCTL support */
struct fw_mgmt_ioc_get_intf_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u16 major;
__u16 minor;
} __attribute__ ((__packed__));
struct fw_mgmt_ioc_get_backend_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u16 major;
__u16 minor;
__u8 status;
} __attribute__ ((__packed__));
struct fw_mgmt_ioc_intf_load_and_validate {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u8 load_method;
__u8 status;
__u16 major;
@ -104,7 +104,7 @@ struct fw_mgmt_ioc_intf_load_and_validate {
} __attribute__ ((__packed__));
struct fw_mgmt_ioc_backend_fw_update {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u8 status;
} __attribute__ ((__packed__));

View File

@ -276,11 +276,11 @@ struct gb_apb_request_cport_flags {
#define GB_FW_DOWNLOAD_TYPE_FETCH_FIRMWARE 0x02
#define GB_FW_DOWNLOAD_TYPE_RELEASE_FIRMWARE 0x03
#define GB_FIRMWARE_TAG_MAX_LEN 10
#define GB_FIRMWARE_TAG_MAX_SIZE 10
/* firmware download find firmware request/response */
struct gb_fw_download_find_firmware_request {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
} __packed;
struct gb_fw_download_find_firmware_response {
@ -340,7 +340,7 @@ struct gb_fw_download_release_firmware_request {
/* firmware management interface firmware version request has no payload */
struct gb_fw_mgmt_interface_fw_version_response {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
__le16 major;
__le16 minor;
} __packed;
@ -349,7 +349,7 @@ struct gb_fw_mgmt_interface_fw_version_response {
struct gb_fw_mgmt_load_and_validate_fw_request {
__u8 request_id;
__u8 load_method;
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
} __packed;
/* firmware management load and validate firmware response has no payload*/
@ -364,7 +364,7 @@ struct gb_fw_mgmt_loaded_fw_request {
/* firmware management backend firmware version request/response */
struct gb_fw_mgmt_backend_fw_version_request {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
} __packed;
struct gb_fw_mgmt_backend_fw_version_response {
@ -376,7 +376,7 @@ struct gb_fw_mgmt_backend_fw_version_response {
/* firmware management backend firmware update request */
struct gb_fw_mgmt_backend_fw_update_request {
__u8 request_id;
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
} __packed;
/* firmware management backend firmware update response has no payload */