From 250c9cd76a494632dee20bb0bca5dc0598cef930 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 9 Feb 2023 19:50:03 +0300 Subject: [PATCH] scst: Fix a version string mismatch Make the SCST_VERSION_STRING macro revision-independent, because it causes a version string mismatch for SCST-dependent modules where the revision is not exported. Fixes: a86e5c55ea78 ("Makefile, scst: Add revision to SCST version macro") Fixes: https://github.com/SCST-project/scst/issues/130 --- scst/include/scst_const.h | 14 +++++++------- scst/src/Kbuild | 2 +- scst/src/scst_main.c | 10 +++++----- scst/src/scst_sysfs.c | 3 ++- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index b1659600f..8b117caa5 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -49,15 +49,15 @@ #define SCST_VERSION(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + d) #define SCST_VERSION_CODE SCST_VERSION(3, 8, 0, 0) -#ifdef SCST_VERSION_REVISION -#define SCST_VERSION_REVISION_SUFFIX "." SCST_STRINGIFY(SCST_VERSION_REVISION) -#else -#define SCST_VERSION_REVISION_SUFFIX "" -#endif - #define SCST_VERSION_STRING_SUFFIX #define SCST_VERSION_NAME "3.8.0-pre" -#define SCST_VERSION_STRING SCST_VERSION_NAME SCST_VERSION_STRING_SUFFIX SCST_VERSION_REVISION_SUFFIX +#define SCST_VERSION_STRING SCST_VERSION_NAME SCST_VERSION_STRING_SUFFIX + +#ifdef SCST_REVISION +#define SCST_REVISION_STRING SCST_STRINGIFY(SCST_REVISION) +#else +#define SCST_REVISION_STRING "" +#endif #define SCST_CONST_VERSION SCST_CONST_INTF_VER diff --git a/scst/src/Kbuild b/scst/src/Kbuild index 29af97767..6133bfe9e 100644 --- a/scst/src/Kbuild +++ b/scst/src/Kbuild @@ -3,7 +3,7 @@ ccflags-y += -I$(src)/../include \ -DDEFAULT_SYMBOL_NAMESPACE=SCST \ $(shell [ -n "${CONFIG_SCST_NO_DLM}" ] && echo -DCONFIG_SCST_NO_DLM) \ - $(shell [ -n "${REVISION}" ] && echo -DSCST_VERSION_REVISION=${REVISION}) + $(shell [ -n "${REVISION}" ] && echo -DSCST_REVISION=${REVISION}) #ccflags-y += -DCONFIG_SCST_STRICT_SERIALIZING #ccflags-y += -DCONFIG_SCST_USE_EXPECTED_VALUES diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index d466ec77d..2fdb9d8bd 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -2490,12 +2490,11 @@ static int __init init_scst(void) goto out_thread_free; #ifdef CONFIG_SCST_NO_TOTAL_MEM_CHECKS - PRINT_INFO("SCST version %s loaded successfully (global max mem for commands " - "ignored, per device %dMB)", SCST_VERSION_STRING, scst_max_dev_cmd_mem); + PRINT_INFO("SCST version %s (revision=%s) loaded successfully (global max mem for commands ignored, per device %dMB)", + SCST_VERSION_STRING, SCST_REVISION_STRING, scst_max_dev_cmd_mem); #else - PRINT_INFO("SCST version %s loaded successfully (max mem for " - "commands %dMB, per device %dMB)", SCST_VERSION_STRING, - scst_max_cmd_mem, scst_max_dev_cmd_mem); + PRINT_INFO("SCST version %s (revision=%s) loaded successfully (max mem for commands %dMB, per device %dMB)", + SCST_VERSION_STRING, SCST_REVISION_STRING, scst_max_cmd_mem, scst_max_dev_cmd_mem); #endif scst_print_config(); @@ -2652,3 +2651,4 @@ MODULE_AUTHOR("Vladislav Bolkhovitin"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("SCSI target core"); MODULE_VERSION(SCST_VERSION_STRING); +MODULE_INFO(revision, SCST_REVISION_STRING); diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 8fed1731a..4c83eee32 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -7517,7 +7517,8 @@ static ssize_t scst_version_show(struct kobject *kobj, { TRACE_ENTRY(); - sprintf(buf, "%s\n", SCST_VERSION_STRING); + sprintf(buf, "%s (revision=%s)\n", + SCST_VERSION_STRING, SCST_REVISION_STRING); #ifdef CONFIG_SCST_STRICT_SERIALIZING strcat(buf, "STRICT_SERIALIZING\n");