From: Gleb C. <lna...@ya...> - 2025-03-25 15:59:54
|
Commit: 86d3d4b GitHub URL: https://github.com/SCST-project/scst/commit/86d3d4bb1d1478d1385bfb7f5df57f964a1175af Author: Gleb Chesnokov Date: 2025-03-25T18:57:32+03:00 Log Message: ----------- kbuild: Enable additional compiler warnings Add additional compiler flags to improve code compliance. Modified Paths: -------------- fcst/Kbuild | 30 +++++++--- iscsi-scst/kernel/Kbuild | 20 ++++++- iscsi-scst/kernel/conn.c | 2 +- iscsi-scst/kernel/isert-scst/Kbuild | 24 ++++++-- iscsi-scst/kernel/isert-scst/iser_rdma.c | 7 +-- qla2x00t-32gbit/Kbuild | 17 +++++- qla2x00t-32gbit/qla2x00-target/Kbuild | 19 +++++- qla2x00t/Kbuild | 17 +++++- qla2x00t/qla2x00-target/Kbuild | 19 +++++- scst/src/Kbuild | 46 ++++++++++----- scst/src/dev_handlers/Kbuild | 21 ++++++- scst/src/scst_mem.c | 6 +- scst/src/scst_sysfs.c | 35 ++++++----- scst_local/Kbuild | 20 ++++++- srpt/src/Kbuild | 19 +++++- 15 files changed, 237 insertions(+), 65 deletions(-) =================================================================== diff --git a/fcst/Kbuild b/fcst/Kbuild index be21875..f9e3611 100644 --- a/fcst/Kbuild +++ b/fcst/Kbuild @@ -1,10 +1,26 @@ -KBUILD_EXTRA_SYMBOLS=$(src)/../scst/src/Module.symvers -ccflags-y += -I$(src)/../scst/include $(shell if [ -e include/scsi ]; then header_dir=.; else header_dir=$$(sed -n 's/^include[[:blank:]]\+\(.*\)\/Makefile$$/\1/p;s/^MAKEARGS := -C \([^ ]*\) .*/\1/p' Makefile); fi; if false; then echo "header_dir=$${header_dir}" >&2; fi; grep -qw fc_fill_fc_hdr "$${header_dir}/include/scsi/fc_encode.h" 2>/dev/null && echo -DFC_FILL_FC_HDR_IN_SCSI_FC_ENCODE_H) +KBUILD_EXTRA_SYMBOLS = $(src)/../scst/src/Module.symvers + +ccflags-y := -I$(src)/../scst/include $(shell if [ -e include/scsi ]; then header_dir=.; else header_dir=$$(sed -n 's/^include[[:blank:]]\+\(.*\)\/Makefile$$/\1/p;s/^MAKEARGS := -C \([^ ]*\) .*/\1/p' Makefile); fi; if false; then echo "header_dir=$${header_dir}" >&2; fi; grep -qw fc_fill_fc_hdr "$${header_dir}/include/scsi/fc_encode.h" 2>/dev/null && echo -DFC_FILL_FC_HDR_IN_SCSI_FC_ENCODE_H) + +ccflags-y += -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes obj-$(CONFIG_FCST) += fcst.o -fcst-objs := \ - ft_cmd.o \ - ft_io.o \ - ft_scst.o \ - ft_sess.o +fcst-objs := ft_cmd.o \ + ft_io.o \ + ft_scst.o \ + ft_sess.o diff --git a/iscsi-scst/kernel/Kbuild b/iscsi-scst/kernel/Kbuild index c6d3340..6fa853e 100644 --- a/iscsi-scst/kernel/Kbuild +++ b/iscsi-scst/kernel/Kbuild @@ -16,7 +16,24 @@ KBUILD_EXTRA_SYMBOLS = $(src)/../../scst/src/Module.symvers -ccflags-y += -I$(src)/../include -I$(src)/../../scst/include +ccflags-y := -I$(src)/../include \ + -I$(src)/../../scst/include \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes + ccflags-y += $(CONFTEST_CFLAGS) #ccflags-y += -DCONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES @@ -24,4 +41,3 @@ obj-m += iscsi-scst.o iscsi-scst-objs := iscsi.o nthread.o config.o digest.o \ conn.o session.o target.o event.o param.o \ iscsit_transport.o - diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index 212e973..fdeffc9 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -269,7 +269,7 @@ restart: } res = kobject_init_and_add(&conn->conn_kobj, &iscsi_conn_ktype, - scst_sysfs_get_sess_kobj(session->scst_sess), addr); + scst_sysfs_get_sess_kobj(session->scst_sess), "%s", addr); if (res != 0) { PRINT_ERROR("Unable create sysfs entries for conn %s", addr); diff --git a/iscsi-scst/kernel/isert-scst/Kbuild b/iscsi-scst/kernel/isert-scst/Kbuild index b6ecd0c..e6ecfa6 100644 --- a/iscsi-scst/kernel/isert-scst/Kbuild +++ b/iscsi-scst/kernel/isert-scst/Kbuild @@ -15,16 +15,30 @@ # GNU General Public License for more details. LINUXINCLUDE := $(ISER_CFLAGS) $(LINUXINCLUDE) -KBUILD_EXTRA_SYMBOLS+=$(src)/../../../scst/src/Module.symvers -KBUILD_EXTRA_SYMBOLS+= \ +KBUILD_EXTRA_SYMBOLS += $(src)/../../../scst/src/Module.symvers +KBUILD_EXTRA_SYMBOLS += \ $(src)/../../kernel/Module.symvers \ $(shell for d in /usr/src/ofa_kernel/default/Module.symvers; do \ [ -e $$d ] || continue; echo $$d; break; done) -ccflags-y += -I$(src)/../../../scst/include -ccflags-y += -I$(src)/../../include +ccflags-y := -I$(src)/../../../scst/include \ + -I$(src)/../../include \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes obj-m += isert-scst.o isert-scst-objs := isert.o isert_login.o \ iser_datamover.o iser_rdma.o iser_buf.o iser_pdu.o iser_global.o - diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index a096d6f..3971106 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -901,7 +901,6 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) struct ib_mr *mr; #endif struct ib_cq *cq; - char wq_name[64]; int i, j; TRACE_ENTRY(); @@ -975,9 +974,9 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) cq_desc->idx = i; INIT_WORK(&cq_desc->cq_comp_work, isert_cq_comp_work_cb); - snprintf(wq_name, sizeof(wq_name), "isert_cq_%p", cq_desc); - cq_desc->cq_workqueue = alloc_workqueue(wq_name, - WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1); + cq_desc->cq_workqueue = alloc_workqueue("isert_cq_%p", + WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1, + cq_desc); if (unlikely(!cq_desc->cq_workqueue)) { PRINT_ERROR("Failed to alloc iser cq work queue for dev:%s", ib_dev->name); diff --git a/qla2x00t-32gbit/Kbuild b/qla2x00t-32gbit/Kbuild index a975475..31cb059 100644 --- a/qla2x00t-32gbit/Kbuild +++ b/qla2x00t-32gbit/Kbuild @@ -1,4 +1,19 @@ -ccflags-y := -I$(src)/../scst/include -I$(src)/include +ccflags-y := -I$(src)/../scst/include \ + -I$(src)/include \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes ifneq ($(CONFIG_SCSI_QLA2XXX_TARGET),) ccflags-y += -DCONFIG_SCSI_QLA2XXX_TARGET=$(CONFIG_SCSI_QLA2XXX_TARGET) diff --git a/qla2x00t-32gbit/qla2x00-target/Kbuild b/qla2x00t-32gbit/qla2x00-target/Kbuild index c3b0c09..24251e3 100644 --- a/qla2x00t-32gbit/qla2x00-target/Kbuild +++ b/qla2x00t-32gbit/qla2x00-target/Kbuild @@ -1,6 +1,23 @@ KBUILD_EXTRA_SYMBOLS = $(src)/../../scst/src/Module.symvers \ $(src)/../Module.symvers -ccflags-y += -I$(src)/../../scst/include -I$(src)/.. +ccflags-y := -I$(src)/../../scst/include \ + -I$(src)/.. \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes + #ccflags-y += -DCONFIG_QLA_TGT_DEBUG_WORK_IN_THREAD #ccflags-y += -DCONFIG_QLA_TGT_DEBUG_SRR diff --git a/qla2x00t/Kbuild b/qla2x00t/Kbuild index f0eab43..e3deaec 100644 --- a/qla2x00t/Kbuild +++ b/qla2x00t/Kbuild @@ -1,4 +1,19 @@ -ccflags-y := -I$(src)/../scst/include +ccflags-y := -I$(src)/../scst/include \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes ifneq ($(CONFIG_SCSI_QLA2XXX_TARGET),) ccflags-y += -DCONFIG_SCSI_QLA2XXX_TARGET=$(CONFIG_SCSI_QLA2XXX_TARGET) diff --git a/qla2x00t/qla2x00-target/Kbuild b/qla2x00t/qla2x00-target/Kbuild index be16e05..9f78e1b 100644 --- a/qla2x00t/qla2x00-target/Kbuild +++ b/qla2x00t/qla2x00-target/Kbuild @@ -1,6 +1,23 @@ KBUILD_EXTRA_SYMBOLS = $(src)/../../scst/src/Module.symvers \ $(src)/../Module.symvers -ccflags-y += -I$(src)/../../scst/include -I$(src)/.. +ccflags-y := -I$(src)/../../scst/include \ + -I$(src)/.. \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes + #ccflags-y += -DCONFIG_QLA_TGT_DEBUG_WORK_IN_THREAD #ccflags-y += -DCONFIG_QLA_TGT_DEBUG_SRR diff --git a/scst/src/Kbuild b/scst/src/Kbuild index 425e128..de1df2e 100644 --- a/scst/src/Kbuild +++ b/scst/src/Kbuild @@ -1,4 +1,19 @@ -ccflags-y := -I$(src)/../include +ccflags-y := -I$(src)/../include \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes ccflags-y += $(shell [ -n "${CONFIG_SCST_NO_DLM}" ] && echo -DCONFIG_SCST_NO_DLM) \ $(shell [ -n "${REVISION}" ] && echo -DSCST_REVISION=${REVISION}) @@ -20,17 +35,18 @@ ccflags-y += $(shell [ -n "${CONFIG_SCST_NO_DLM}" ] && echo -DCONFIG_SCST_NO_DLM obj-m := scst.o -scst-y += scst_copy_mgr.o -scst-y += scst_debug.o -scst-y += scst_dlm.o -scst-y += scst_event.o -scst-y += scst_lib.o -scst-y += scst_local_cmd.o -scst-y += scst_main.o -scst-y += scst_mem.o -scst-y += scst_no_dlm.o -scst-y += scst_pres.o -scst-y += scst_sysfs.o -scst-y += scst_targ.o -scst-y += scst_tg.o -obj-$(CONFIG_SCST) += scst.o dev_handlers/ +scst-y += scst_copy_mgr.o \ + scst_debug.o \ + scst_dlm.o \ + scst_event.o \ + scst_lib.o \ + scst_local_cmd.o \ + scst_main.o \ + scst_mem.o \ + scst_no_dlm.o \ + scst_pres.o \ + scst_sysfs.o \ + scst_targ.o \ + scst_tg.o + +obj-$(CONFIG_SCST) += scst.o dev_handlers/ diff --git a/scst/src/dev_handlers/Kbuild b/scst/src/dev_handlers/Kbuild index 4674acc..8a813a1 100644 --- a/scst/src/dev_handlers/Kbuild +++ b/scst/src/dev_handlers/Kbuild @@ -1,5 +1,22 @@ -KBUILD_EXTRA_SYMBOLS=$(src)/../Module.symvers -ccflags-y += -I$(src)/../../include +KBUILD_EXTRA_SYMBOLS = $(src)/../Module.symvers + +ccflags-y := -I$(src)/../../include \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes + #ccflags-y += -DCONFIG_DEBUG_EXT_COPY_REMAP obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \ diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 821d6b3..1e5c209 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -2080,8 +2080,8 @@ static int scst_sgv_sysfs_create(struct sgv_pool *pool) TRACE_ENTRY(); - res = kobject_init_and_add(&pool->sgv_kobj, &sgv_pool_ktype, - scst_sgv_kobj, pool->name); + res = kobject_init_and_add(&pool->sgv_kobj, &sgv_pool_ktype, scst_sgv_kobj, "%s", + pool->name); if (res != 0) { PRINT_ERROR("Can't add sgv pool %s to sysfs", pool->name); goto out; @@ -2147,7 +2147,7 @@ int scst_add_sgv_kobj(struct kobject *parent, const char *name) scst_sgv_kobj = kzalloc(sizeof(*scst_sgv_kobj), GFP_KERNEL); if (!scst_sgv_kobj) goto out; - res = kobject_init_and_add(scst_sgv_kobj, &sgv_ktype, parent, name); + res = kobject_init_and_add(scst_sgv_kobj, &sgv_ktype, parent, "%s", name); if (res != 0) goto out_free; out: diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index a336558..1695eb9 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1083,8 +1083,8 @@ int scst_tgtt_sysfs_create(struct scst_tgt_template *tgtt) TRACE_ENTRY(); - res = kobject_init_and_add(&tgtt->tgtt_kobj, &tgtt_ktype, - scst_targets_kobj, tgtt->name); + res = kobject_init_and_add(&tgtt->tgtt_kobj, &tgtt_ktype, scst_targets_kobj, "%s", + tgtt->name); if (res != 0) { PRINT_ERROR("Can't add tgtt %s to sysfs", tgtt->name); goto out; @@ -3019,8 +3019,8 @@ int scst_tgt_sysfs_create(struct scst_tgt *tgt) TRACE_ENTRY(); - res = kobject_init_and_add(&tgt->tgt_kobj, &tgt_ktype, - &tgt->tgtt->tgtt_kobj, tgt->tgt_name); + res = kobject_init_and_add(&tgt->tgt_kobj, &tgt_ktype, &tgt->tgtt->tgtt_kobj, "%s", + tgt->tgt_name); if (res != 0) { PRINT_ERROR("Can't add tgt %s to sysfs", tgt->tgt_name); goto out; @@ -3983,8 +3983,8 @@ int scst_dev_sysfs_create(struct scst_device *dev) TRACE_ENTRY(); - res = kobject_init_and_add(&dev->dev_kobj, &scst_dev_ktype, - scst_devices_kobj, dev->virt_name); + res = kobject_init_and_add(&dev->dev_kobj, &scst_dev_ktype, scst_devices_kobj, "%s", + dev->virt_name); if (res != 0) { PRINT_ERROR("Can't add device %s to sysfs", dev->virt_name); goto out; @@ -4370,8 +4370,8 @@ int scst_tgt_dev_sysfs_create(struct scst_tgt_dev *tgt_dev) TRACE_ENTRY(); res = kobject_init_and_add(&tgt_dev->tgt_dev_kobj, &scst_tgt_dev_ktype, - &tgt_dev->sess->sess_kobj, "lun%lld", - (unsigned long long)tgt_dev->lun); + &tgt_dev->sess->sess_kobj, "lun%lld", + (unsigned long long)tgt_dev->lun); if (res != 0) { PRINT_ERROR("Can't add tgt_dev %lld to sysfs", (unsigned long long)tgt_dev->lun); @@ -5049,8 +5049,8 @@ int scst_sess_sysfs_create(struct scst_session *sess) name = sess->sess_name; TRACE_DBG("Adding session %s to sysfs", name); - res = kobject_init_and_add(&sess->sess_kobj, &scst_session_ktype, - sess->tgt->tgt_sess_kobj, name); + res = kobject_init_and_add(&sess->sess_kobj, &scst_session_ktype, sess->tgt->tgt_sess_kobj, + "%s", name); if (res != 0) { PRINT_ERROR("Can't add session %s to sysfs", name); goto out; @@ -5229,8 +5229,8 @@ int scst_acg_dev_sysfs_create(struct scst_acg_dev *acg_dev, TRACE_ENTRY(); - res = kobject_init_and_add(&acg_dev->acg_dev_kobj, &acg_dev_ktype, - parent, "%llu", acg_dev->lun); + res = kobject_init_and_add(&acg_dev->acg_dev_kobj, &acg_dev_ktype, parent, "%llu", + acg_dev->lun); if (res != 0) { PRINT_ERROR("Can't add acg_dev %p to sysfs", acg_dev); goto out; @@ -5647,8 +5647,8 @@ int scst_acg_sysfs_create(struct scst_tgt *tgt, TRACE_ENTRY(); - res = kobject_init_and_add(&acg->acg_kobj, &acg_ktype, - tgt->tgt_ini_grp_kobj, acg->acg_name); + res = kobject_init_and_add(&acg->acg_kobj, &acg_ktype, tgt->tgt_ini_grp_kobj, "%s", + acg->acg_name); if (res != 0) { PRINT_ERROR("Can't add acg '%s' to sysfs", acg->acg_name); goto out; @@ -6257,8 +6257,7 @@ int scst_devt_sysfs_create(struct scst_dev_type *devt) else parent = scst_handlers_kobj; - res = kobject_init_and_add(&devt->devt_kobj, &scst_devt_ktype, - parent, devt->name); + res = kobject_init_and_add(&devt->devt_kobj, &scst_devt_ktype, parent, "%s", devt->name); if (res != 0) { PRINT_ERROR("Can't add devt %s to sysfs", devt->name); goto out; @@ -8025,8 +8024,8 @@ int __init scst_sysfs_init(void) goto out; } - res = kobject_init_and_add(&scst_sysfs_root_kobj, - &scst_sysfs_root_ktype, kernel_kobj, "%s", "scst_tgt"); + res = kobject_init_and_add(&scst_sysfs_root_kobj, &scst_sysfs_root_ktype, kernel_kobj, + "%s", "scst_tgt"); if (res != 0) goto sysfs_root_add_error; diff --git a/scst_local/Kbuild b/scst_local/Kbuild index 115020e..0e9a878 100644 --- a/scst_local/Kbuild +++ b/scst_local/Kbuild @@ -1,4 +1,20 @@ KBUILD_EXTRA_SYMBOLS=$(src)/../scst/src/Module.symvers -ccflags-y += -I$(src)/../scst/include -obj-m := scst_local.o +ccflags-y := -I$(src)/../scst/include \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes + +obj-m := scst_local.o diff --git a/srpt/src/Kbuild b/srpt/src/Kbuild index 990eacd..6962b26 100644 --- a/srpt/src/Kbuild +++ b/srpt/src/Kbuild @@ -1,8 +1,23 @@ LINUXINCLUDE := $(CONFTEST_CFLAGS) $(LINUXINCLUDE) -KBUILD_EXTRA_SYMBOLS=$(src)/../../scst/src/Module.symvers \ +KBUILD_EXTRA_SYMBOLS = $(src)/../../scst/src/Module.symvers \ $(shell for d in /usr/src/ofa_kernel/default/Module.symvers; do\ [ -e $$d ] || continue; echo $$d; break; done) -ccflags-y += -I$(src)/../../scst/include +ccflags-y += -I$(src)/../../scst/include \ + -Wall \ + -Wextra \ + -Wno-type-limits \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter \ + -Wformat \ + -O2 \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -pipe \ + -g \ + -grecord-gcc-switches \ + -fstack-clash-protection \ + -fstack-protector-strong \ + -Wstrict-prototypes obj-m += ib_srpt.o |