• Sebastian Kemper's avatar
    FS-11783: [core] quiet gcc truncation warning · e114c638
    Sebastian Kemper 提交于
    With -Wstringop-truncation gcc warns about calls to bounded string
    manipulation function "strncpy" that may either truncate the copied
    string or leave the destination unchanged. To avoid the warning when the
    result is not expected to be NUL-terminated, it is suggested to call
    "memcpy" instead.
    
    src/switch_core_media.c: In function 'switch_core_media_patch_sdp':
    src/switch_core_media.c:11854:4: error: 'strncpy' output truncated before terminating nul copying 2 bytes from a string of the same length [-Werror=stringop-truncation]
        strncpy(q, strchr(a_engine->adv_sdp_ip, ':') ? "6 " : "4 ", 2);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    This commit follows gcc's recommendation.
    Signed-off-by: 's avatarSebastian Kemper <sebastian_ml@gmx.net>
    e114c638
switch_core_media.c 510.4 KB