Skip to content

Commit 1359798

Browse files
mwilckChristoph Hellwig
authored andcommitted
string.h: un-fortify memcpy_and_pad
The way I'd implemented the new helper memcpy_and_pad with __FORTIFY_INLINE caused compiler warnings for certain kernel configurations. This helper is only used in a single place at this time, and thus doesn't benefit much from fortification. So simplify the code by dropping fortification support for now. Fixes: 01f33c3 "string.h: add memcpy_and_pad()" Signed-off-by: Martin Wilck <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 044a9df commit 1359798

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

include/linux/string.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -434,20 +434,9 @@ __FORTIFY_INLINE char *strcpy(char *p, const char *q)
434434
* @count: The number of bytes to copy
435435
* @pad: Character to use for padding if space is left in destination.
436436
*/
437-
__FORTIFY_INLINE void memcpy_and_pad(void *dest, size_t dest_len,
438-
const void *src, size_t count, int pad)
437+
static inline void memcpy_and_pad(void *dest, size_t dest_len,
438+
const void *src, size_t count, int pad)
439439
{
440-
size_t dest_size = __builtin_object_size(dest, 0);
441-
size_t src_size = __builtin_object_size(src, 0);
442-
443-
if (__builtin_constant_p(dest_len) && __builtin_constant_p(count)) {
444-
if (dest_size < dest_len && dest_size < count)
445-
__write_overflow();
446-
else if (src_size < dest_len && src_size < count)
447-
__read_overflow3();
448-
}
449-
if (dest_size < dest_len)
450-
fortify_panic(__func__);
451440
if (dest_len > count) {
452441
memcpy(dest, src, count);
453442
memset(dest + count, pad, dest_len - count);

0 commit comments

Comments
 (0)