intel / ledmon

Enclosure LED Utilities
GNU General Public License v2.0
72 stars 44 forks source link

utils.c: Check snprintf return code #177

Closed tasleson closed 9 months ago

tasleson commented 9 months ago

Fixes the compiler error I'm running into when building test packages on fedora.

In function 'get_text_to_dest',
    inlined from '_amd_sgpio_em_enabled' at ../lib/amd_sgpio.c:815:6,
    inlined from 'amd_em_enabled' at ../lib/amd.c:130:8,
    inlined from 'cntrl_device_init' at ../lib/cntrl.c:424:17,
    inlined from '_cntrl_add' at ../lib/sysfs.c:284:32,
    inlined from '_check_cntrl' at ../lib/sysfs.c:327:3:
../lib/utils.c:83:38: error: '%s' directive output may be truncated
    writing 20 bytes into a region of size between 0 and 4095
        [-Werror=format-truncation=]
   83 |         snprintf(temp, sizeof(temp), "%s/%s", path, name);

Test rpm packages: https://copr.fedorainfracloud.org/coprs/tasleson/ledmon-upstream/