mirror of
https://github.com/SCST-project/scst.git
synced 2026-10-22 06:02:33 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user