From: Christian Lamparter Date: Thu, 13 Jan 2011 13:45:51 +0000 (+0100) Subject: carl9170 firmware tools: fix libcarlfw on 64bit cpus X-Git-Tag: 1.9.3~22 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=f2e3ff4fb3fc8c2f1d6678014a49b048f1e3beaf;p=carl9170fw.git carl9170 firmware tools: fix libcarlfw on 64bit cpus Signed-off-by: Christian Lamparter --- diff --git a/include/shared/fwdesc.h b/include/shared/fwdesc.h index 71f3821..b5428d6 100644 --- a/include/shared/fwdesc.h +++ b/include/shared/fwdesc.h @@ -88,8 +88,10 @@ enum carl9170fw_feature_list { #define CARL9170FW_GET_MONTH(m) ((((m) / 31) % 12) + 1) #define CARL9170FW_GET_YEAR(y) ((y) / 372 + 10) +#define CARL9170FW_MAGIC_SIZE 4 + struct carl9170fw_desc_head { - u8 magic[4]; + u8 magic[CARL9170FW_MAGIC_SIZE]; __le16 length; u8 min_ver; u8 cur_ver; @@ -189,8 +191,8 @@ struct carl9170fw_last_desc { } static inline void carl9170fw_fill_desc(struct carl9170fw_desc_head *head, - u8 magic[4], __le16 length, - u8 min_ver, u8 cur_ver) + u8 magic[CARL9170FW_MAGIC_SIZE], + __le16 length, u8 min_ver, u8 cur_ver) { head->magic[0] = magic[0]; head->magic[1] = magic[1]; @@ -204,7 +206,7 @@ static inline void carl9170fw_fill_desc(struct carl9170fw_desc_head *head, #define carl9170fw_for_each_hdr(desc, fw_desc) \ for (desc = fw_desc; \ - memcmp(desc->magic, LAST_MAGIC, 4) && \ + memcmp(desc->magic, LAST_MAGIC, CARL9170FW_MAGIC_SIZE) && \ le16_to_cpu(desc->length) >= CARL9170FW_DESC_HEAD_SIZE && \ le16_to_cpu(desc->length) < CARL9170FW_DESC_MAX_LENGTH; \ desc = (void *)((unsigned long)desc + le16_to_cpu(desc->length))) @@ -218,8 +220,8 @@ static inline bool carl9170fw_supports(__le32 list, u8 feature) } static inline bool carl9170fw_desc_cmp(const struct carl9170fw_desc_head *head, - const u8 descid[4], u16 min_len, - u8 compatible_revision) + const u8 descid[CARL9170FW_MAGIC_SIZE], + u16 min_len, u8 compatible_revision) { if (descid[0] == head->magic[0] && descid[1] == head->magic[1] && descid[2] == head->magic[2] && descid[3] == head->magic[3] && diff --git a/tools/lib/carlfw.c b/tools/lib/carlfw.c index b752535..44897e3 100644 --- a/tools/lib/carlfw.c +++ b/tools/lib/carlfw.c @@ -190,18 +190,18 @@ static void *__carlfw_find_desc(struct carlfw_file *file, struct carl9170fw_desc_head *tmp = NULL; while (scan >= 0) { - if (file->data[scan] == descid[sizeof(descid) - found - 1]) + if (file->data[scan] == descid[CARL9170FW_MAGIC_SIZE - found - 1]) found++; else found = 0; - if (found == sizeof(descid)) + if (found == CARL9170FW_MAGIC_SIZE) break; scan--; } - if (found == sizeof(descid)) { + if (found == CARL9170FW_MAGIC_SIZE) { tmp = (void *) &file->data[scan]; if (!CHECK_HDR_VERSION(tmp, compatible_revision) &&