From ff99b19a9a9644d6125f3681596effd50228a3ce Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Tue, 20 Oct 2026 16:09:40 +0300 Subject: [PATCH] scst: Keep compatibility branches inside complete statements Coccinelle emits "parse error" while recovering from BIO callbacks whose opening braces occur separately in the two signature branches. The raw log includes this fragment of scst/src/dev_handlers/scst_vdisk_main.c: bad: static void vdev_flush_end_io(struct bio *bio, int error) bad: { bad: #else Move the opening brace below the signature conditional in vdev_flush_end_io, blockio_end_sync_io, blockio_endio and blk_bio_map_kern_endio. Keep version-specific local error extraction inside its existing compatibility condition. Also bracket the conditional max_nr_vecs assignment in blockio_exec_rw and the sendpage fast path in write_data. Initialize the legacy sock_no_sendpage fallback before the fast path so an else no longer appears in only one preprocessor branch. These changes address parser failures, not runtime warnings. All kernel compatibility conditions are retained. Preprocessed token comparisons covering 56 kernel-version/SUSE combinations show unchanged C code. --- iscsi-scst/kernel/nthread.c | 8 +++++--- scst/src/dev_handlers/scst_vdisk_main.c | 14 +++++++++----- scst/src/scst_lib.c | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 537a1a5f5..c978bdbc1 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -1163,16 +1163,18 @@ int write_data(struct iscsi_conn *conn) sock = conn->sock; flags = MSG_DONTWAIT; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) + sock_sendpage = sock_no_sendpage; +#endif if (sg != write_cmnd->rsp_sg && (!parent_req->scst_cmd || parent_req->scst_state == ISCSI_CMD_STATE_AEN || - !scst_cmd_get_dh_data_buff_alloced(parent_req->scst_cmd))) + !scst_cmd_get_dh_data_buff_alloced(parent_req->scst_cmd))) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) flags |= MSG_SPLICE_PAGES; #else sock_sendpage = sock->ops->sendpage; - else - sock_sendpage = sock_no_sendpage; #endif + } sg_size = size; diff --git a/scst/src/dev_handlers/scst_vdisk_main.c b/scst/src/dev_handlers/scst_vdisk_main.c index a60c00751..e22b93b3d 100644 --- a/scst/src/dev_handlers/scst_vdisk_main.c +++ b/scst/src/dev_handlers/scst_vdisk_main.c @@ -239,10 +239,11 @@ static struct file *vdev_open_fd(const struct scst_vdisk_dev *virt_dev, const ch #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) static void vdev_flush_end_io(struct bio *bio, int error) -{ #else static void vdev_flush_end_io(struct bio *bio) +#endif { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && \ !defined(CONFIG_SUSE_KERNEL) int error = bio->bi_error; @@ -2709,10 +2710,11 @@ struct bio_priv_sync { #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) static void blockio_end_sync_io(struct bio *bio, int error) -{ #else static void blockio_end_sync_io(struct bio *bio) +#endif { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && \ !defined(CONFIG_SUSE_KERNEL) int error = bio->bi_error; @@ -5534,10 +5536,11 @@ static inline void blockio_check_finish(struct scst_blockio_work *blockio_work) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) static void blockio_endio(struct bio *bio, int error) -{ #else static void blockio_endio(struct bio *bio) +#endif { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && \ !defined(CONFIG_SUSE_KERNEL) int error = bio->bi_error; @@ -5790,14 +5793,15 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua) blockio_work->cmd = cmd; - if (q) + if (q) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) max_nr_vecs = BIO_MAX_VECS; #else max_nr_vecs = min(bio_get_nr_vecs(bdev), BIO_MAX_VECS); #endif - else + } else { max_nr_vecs = 1; + } need_new_bio = 1; diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index e661e80bc..6295f1dc1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -8201,10 +8201,11 @@ static inline void scst_free_bio(struct bio *bio); #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) static void blk_bio_map_kern_endio(struct bio *bio, int err) -{ #else static void blk_bio_map_kern_endio(struct bio *bio) +#endif { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && \ !defined(CONFIG_SUSE_KERNEL) int err = bio->bi_error;