mirror of https://github.com/sipwise/sems.git
It's been noticed that we are using `memcpy` for copying of the data,
where the source and destination overlaps.
This begets the following warning:
In function 'memcpy',
inlined from 'Decode' at iLBC_decode.c:254:16:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:10: warning: '__builtin_memcpy' accessing 428 bytes at offsets 0 and 160 overlaps 268 bytes at offset 160 [-Wrestrict]
34 | return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'memcpy',
inlined from 'Decode' at iLBC_decode.c:302:16:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:10: warning: '__builtin_memcpy' accessing 428 bytes at offsets 0 and 160 overlaps 268 bytes at offset 160 [-Wrestrict]
34 | return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/string.h:495,
from iLBC_encode.c:15:
In function 'memcpy',
inlined from 'iLBC_encode' at iLBC_encode.c:311:16:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:10: warning: '__builtin_memcpy' accessing 428 bytes at offsets 0 and 160 overlaps 268 bytes at offset 160 [-Wrestrict]
34 | return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'memcpy',
inlined from 'iLBC_encode' at iLBC_encode.c:389:16:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:10: warning: '__builtin_memcpy' accessing 428 bytes at offsets 0 and 160 overlaps 268 bytes at offset 160 [-Wrestrict]
34 | return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The problem is that `memcpy` should not be used, when dst memory overlaps with src memory.
We should update such usage of `memcpy` and swap it with `memmove`
From the manpage of the `memcpy`:
>> The memory areas should not overlap. Use memmove(3) if the memory areas do overlap.
Change-Id: I5e3e65587fad92c91bb298e4e5415db1fd0c0371
mr11.4.1
parent
1a25a841d8
commit
7d750052f1
Loading…
Reference in new issue