kbuild: Enable additional compiler warnings

Add additional compiler flags to improve code compliance.
This commit is contained in:
Gleb Chesnokov
2025-03-25 17:56:31 +03:00
parent 12a00ffc89
commit 86d3d4bb1d
15 changed files with 237 additions and 65 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

@@ -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);

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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/

View File

@@ -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 \

View File

@@ -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:

View File

@@ -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;

View File

@@ -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

View File

@@ -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