Skip to content

Commit 440e205

Browse files
nathanchancekeithbusch
authored andcommitted
nvmet-fc: Remove __counted_by from nvmet_fc_tgt_queue.fod[]
Work for __counted_by on generic pointers in structures (not just flexible array members) has started landing in Clang 19 (current tip of tree). During the development of this feature, a restriction was added to __counted_by to prevent the flexible array member's element type from including a flexible array member itself such as: struct foo { int count; char buf[]; }; struct bar { int count; struct foo data[] __counted_by(count); }; because the size of data cannot be calculated with the standard array size formula: sizeof(struct foo) * count This restriction was downgraded to a warning but due to CONFIG_WERROR, it can still break the build. The application of __counted_by on the fod member of 'struct nvmet_fc_tgt_queue' triggers this restriction, resulting in: drivers/nvme/target/fc.c:151:2: error: 'counted_by' should not be applied to an array with element of unknown size because 'struct nvmet_fc_fcp_iod' is a struct type with a flexible array member. This will be an error in a future compiler version [-Werror,-Wbounds-safety-counted-by-elt-type-unknown-size] 151 | struct nvmet_fc_fcp_iod fod[] __counted_by(sqsize); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Remove this use of __counted_by to fix the warning/error. However, rather than remove it altogether, leave it commented, as it may be possible to support this in future compiler releases. Cc: [email protected] Closes: ClangBuiltLinux#2027 Fixes: ccd3129 ("nvmet-fc: Annotate struct nvmet_fc_tgt_queue with __counted_by") Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 0f1f580 commit 440e205

File tree

1 file changed

+1
-1
lines changed
  • drivers/nvme/target

1 file changed

+1
-1
lines changed

drivers/nvme/target/fc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct nvmet_fc_tgt_queue {
148148
struct workqueue_struct *work_q;
149149
struct kref ref;
150150
/* array of fcp_iods */
151-
struct nvmet_fc_fcp_iod fod[] __counted_by(sqsize);
151+
struct nvmet_fc_fcp_iod fod[] /* __counted_by(sqsize) */;
152152
} __aligned(sizeof(unsigned long long));
153153

154154
struct nvmet_fc_hostport {

0 commit comments

Comments
 (0)