Re: [PATCH v1 2/2] io_uring: uapi: Don't use a zero-size array

From: Ammar Faizi
Date: Wed Nov 16 2022 - 05:39:19 EST


On 11/16/22 5:14 PM, Pavel Begunkov wrote:
On 11/15/22 21:29, Ammar Faizi wrote:
From: Ammar Faizi <ammarfaizi2@xxxxxxxxxxx>

Don't use a zero-size array because it doesn't allow the user to
compile an app that uses liburing with the `-pedantic-errors` flag:

Ammar, I'd strongly encourage you to at least compile your
patches or even better actually test them. There is an explicit
BUILD_BUG_ON() violated by this change.

Oh yeah, I didn't realize that. This patch breaks this assertion:

BUILD_BUG_ON failed: sizeof_field(struct io_uring_sqe, cmd) != 0

This assertion wants the size of cmd[] to be zero. Which is obviously
violated in this patch.

I only tested a liburing app that uses this header and validated
that the struct size is the same, but not its field. That's my
mistake.

I'm *not* going to send a v2 per Jens' comment.

--
Ammar Faizi