Skip to content

Commit

Permalink
Fix strings truncation warnings
Browse files Browse the repository at this point in the history
recog_arm.c: In function 'cpuid_identify_arm':
recog_arm.c:2548:9: warning: 'strncpy' specified bound 16 equals destination size [-Wstringop-truncation]
 2548 |         strncpy(data->vendor_str,   hw_impl->name,     VENDOR_STR_MAX);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
recog_arm.c:2549:9: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 2549 |         strncpy(data->brand_str,    id_part->name,     BRAND_STR_MAX);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
recog_arm.c:2550:9: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 2550 |         strncpy(data->cpu_codename, id_part->codename, CODENAME_STR_MAX);
  • Loading branch information
TheTumultuousUnicornOfDarkness committed Aug 25, 2024
1 parent 656ea52 commit 0d8cf47
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libcpuid/recog_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2545,9 +2545,9 @@ int cpuid_identify_arm(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
const struct arm_hw_impl* hw_impl = get_cpu_implementer_from_code(data->arm.implementer);
const struct arm_id_part* id_part = get_cpu_implementer_parts(hw_impl, data->arm.part_num);
data->vendor = hw_impl->vendor;
strncpy(data->vendor_str, hw_impl->name, VENDOR_STR_MAX);
strncpy(data->brand_str, id_part->name, BRAND_STR_MAX);
strncpy(data->cpu_codename, id_part->codename, CODENAME_STR_MAX);
snprintf(data->vendor_str, VENDOR_STR_MAX, "%s", hw_impl->name);
snprintf(data->brand_str, BRAND_STR_MAX, "%s", id_part->name);
snprintf(data->cpu_codename, CODENAME_STR_MAX,"%s", id_part->codename);
use_cpuid_scheme = (decode_arm_architecture_version_by_midr(raw, data) == false);
load_arm_features(raw, data, &ext_status);
if (use_cpuid_scheme)
Expand Down

0 comments on commit 0d8cf47

Please sign in to comment.