Skip to content

Commit

Permalink
Fix compiler warnings about zero-length arrays in inline bitops
Browse files Browse the repository at this point in the history
The compiler appears to be expanding the unused NULL pointer into a
zero-length array via the inline bitops code. When -Werror=array-bounds
is used, this causes a build failure. Recommended solution is allocate
temporary structures, fill with zeros (to avoid uninitialized data use
warnings), and pass the pointer to those to the inline calls.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Coleman Kane <ckane@colemankane.org>
Closes #13463 
Closes #13465
  • Loading branch information
ckane committed May 17, 2022
1 parent 276b08c commit c0cf6ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions config/kernel-blk-queue.m4
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [
ZFS_LINUX_TEST_SRC([blk_queue_discard], [
#include <linux/blkdev.h>
],[
struct request_queue *q __attribute__ ((unused)) = NULL;
struct request_queue r;
struct request_queue *q = &r;
int value __attribute__ ((unused));
memset(q, 0, sizeof(r));
value = blk_queue_discard(q);
])
])
Expand All @@ -119,16 +121,20 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [
ZFS_LINUX_TEST_SRC([blk_queue_secure_erase], [
#include <linux/blkdev.h>
],[
struct request_queue *q __attribute__ ((unused)) = NULL;
struct request_queue r;
struct request_queue *q = &r;
int value __attribute__ ((unused));
memset(q, 0, sizeof(r));
value = blk_queue_secure_erase(q);
])
ZFS_LINUX_TEST_SRC([blk_queue_secdiscard], [
#include <linux/blkdev.h>
],[
struct request_queue *q __attribute__ ((unused)) = NULL;
struct request_queue r;
struct request_queue *q = &r;
int value __attribute__ ((unused));
memset(q, 0, sizeof(r));
value = blk_queue_secdiscard(q);
])
])
Expand Down

0 comments on commit c0cf6ed

Please sign in to comment.