Skip to content

Commit

Permalink
Merge drbd-9.1/8597f3d59 'compat: Workaround for Linux-6.12 bug in co…
Browse files Browse the repository at this point in the history
…mpat test have_strscpy.c'
  • Loading branch information
Philipp-Reisner committed Nov 18, 2024
2 parents 176bec2 + 8597f3d commit 4f3e619
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drbd/drbd-kernel-compat/tests/have_strscpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

#include <linux/string.h>

/*
* For making it compatible with linux-6.12:
* Work around <linux/compiler.h> defines __must_be_array() and __must_be_cstr() and both expand to
* BUILD_BUG_ON_ZERO(), but <linux/build_bug.h> defines BUILD_BUG_ON_ZERO(). <linux/compiler.h> does
* not include <linux/build_bug.h> and Linus does not want that.
*
* See https://lore.kernel.org/linux-kernel/[email protected]/T/#t
*
*/
#ifndef BUILD_BUG_ON_ZERO
#define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
#endif

ssize_t foo(char *dest, const char *src, size_t count)
{
return strscpy(dest, src, count);
Expand Down

0 comments on commit 4f3e619

Please sign in to comment.