From 08ba5d8f1a2e3a68e3103ff6ddacd32ba74faf94 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 12 May 2020 14:57:00 +0000 Subject: [PATCH 1/4] iscsi-scst: Remove unnecessary %s format modifiers See also https://github.com/bvanassche/scst/pull/18. Signed-off-by: Konstantin Kharlamov git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8903 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/config.c | 8 ++++---- iscsi-scst/kernel/conn.c | 2 +- iscsi-scst/kernel/param.c | 4 ++-- iscsi-scst/usr/event.c | 2 +- iscsi-scst/usr/param.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/iscsi-scst/kernel/config.c b/iscsi-scst/kernel/config.c index f6c2628c3..f3a574934 100644 --- a/iscsi-scst/kernel/config.c +++ b/iscsi-scst/kernel/config.c @@ -59,16 +59,16 @@ static ssize_t iscsi_open_state_show(struct kobject *kobj, { switch (ctr_open_state) { case ISCSI_CTR_OPEN_STATE_CLOSED: - sprintf(buf, "%s\n", "closed"); + sprintf(buf, "closed\n"); break; case ISCSI_CTR_OPEN_STATE_OPEN: - sprintf(buf, "%s\n", "open"); + sprintf(buf, "open\n"); break; case ISCSI_CTR_OPEN_STATE_CLOSING: - sprintf(buf, "%s\n", "closing"); + sprintf(buf, "closing\n"); break; default: - sprintf(buf, "%s\n", "unknown"); + sprintf(buf, "unknown\n"); break; } diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index 7e6a96611..640da52e7 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -39,7 +39,7 @@ static int print_conn_state(char *p, size_t size, struct iscsi_conn *conn) int pos = 0; if (conn->closing) { - pos += scnprintf(p, size, "%s", "closing"); + pos += scnprintf(p, size, "closing"); goto out; } diff --git a/iscsi-scst/kernel/param.c b/iscsi-scst/kernel/param.c index 682cf625e..77b1a82fb 100644 --- a/iscsi-scst/kernel/param.c +++ b/iscsi-scst/kernel/param.c @@ -66,14 +66,14 @@ const char *iscsi_get_digest_name(int val, char *res) int pos = 0; if (val & DIGEST_NONE) - pos = sprintf(&res[pos], "%s", "None"); + pos = sprintf(&res[pos], "None"); if (val & DIGEST_CRC32C) pos += sprintf(&res[pos], "%s%s", (pos != 0) ? ", " : "", "CRC32C"); if (pos == 0) - sprintf(&res[pos], "%s", "Unknown"); + sprintf(&res[pos], "Unknown"); return res; } diff --git a/iscsi-scst/usr/event.c b/iscsi-scst/usr/event.c index 0624613dc..61cb13205 100644 --- a/iscsi-scst/usr/event.c +++ b/iscsi-scst/usr/event.c @@ -624,7 +624,7 @@ static int handle_e_get_attr_value(int fd, const struct iscsi_kern_event *event) isns_access_control ? ISCSI_ISNS_SYSFS_ACCESS_CONTROL_ENABLED : ""); add_key_mark(res_str, sizeof(res_str), 0); } else - snprintf(res_str, sizeof(res_str), "%s\n", ""); + snprintf(res_str, sizeof(res_str), "\n"); } else if (strcasecmp(ISCSI_ISNS_ENTITY_ATTR_NAME, pp) == 0) { if (target != NULL) { log_error("Not NULL target %s for global attribute %s", diff --git a/iscsi-scst/usr/param.c b/iscsi-scst/usr/param.c index 463fc92a3..acdcd248e 100644 --- a/iscsi-scst/usr/param.c +++ b/iscsi-scst/usr/param.c @@ -181,7 +181,7 @@ static int digest_val_to_str(unsigned int val, char *str, int len) if (val & DIGEST_NONE) { len -= pos; - pos = snprintf(&str[pos], len, "%s", "None"); + pos = snprintf(&str[pos], len, "None"); } if (pos >= len) @@ -197,7 +197,7 @@ static int digest_val_to_str(unsigned int val, char *str, int len) goto out; if (pos == 0) - pos = snprintf(&str[0], len, "%s", "Unknown"); + pos = snprintf(&str[0], len, "Unknown"); out: return 0; From ee0328f6f72b45d0eb03d206a51a1fb57b111e70 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 13 May 2020 17:23:14 +0000 Subject: [PATCH 2/4] scst: Drop support for scst_register_target(..., NULL) Support for autogenerated target names was declared obsolete in 2011. Remove support for autogenerated target names. See also commit 21d503cbb7d1 ("Autogenerated SCST target names made deprecated"). git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8904 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_main.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 21c1fd517..b6c37ee38 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -464,37 +464,18 @@ struct scst_tgt *scst_register_target(struct scst_tgt_template *vtt, TRACE_ENTRY(); + BUG_ON(!target_name); + rc = scst_alloc_tgt(vtt, &tgt); if (rc != 0) goto out; - if (target_name != NULL) { - - tgt->tgt_name = kstrdup(target_name, GFP_KERNEL); - if (tgt->tgt_name == NULL) { - PRINT_ERROR("Allocation of tgt name %s failed", - target_name); - rc = -ENOMEM; - goto out_free_tgt; - } - } else { - static int tgt_num; /* protected by scst_mutex */ - - PRINT_WARNING("Usage of autogenerated SCST target names " - "is deprecated and will be removed in one of the next " - "versions. It is strongly recommended to update target " - "driver %s to use hardware related persistent target " - "names instead", vtt->name); - - tgt->tgt_name = kasprintf(GFP_KERNEL, "%s%s%d", vtt->name, - SCST_DEFAULT_TGT_NAME_SUFFIX, tgt_num); - if (tgt->tgt_name == NULL) { - PRINT_ERROR("Allocation of tgt name failed " - "(template name %s)", vtt->name); - rc = -ENOMEM; - goto out_free_tgt; - } - tgt_num++; + tgt->tgt_name = kstrdup(target_name, GFP_KERNEL); + if (tgt->tgt_name == NULL) { + PRINT_ERROR("Allocation of tgt name %s failed", + target_name); + rc = -ENOMEM; + goto out_free_tgt; } rc = mutex_lock_interruptible(&scst_mutex); From 858f50e4d39140af537b90af2162588bcbf5d7a0 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 13 May 2020 17:24:35 +0000 Subject: [PATCH 3/4] scstadmin: Improve robustness Instead of only interpreting the empty string as "no argument passed", also consider 'undef' as "no argument passed". git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8905 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/scstadmin | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 361487d06..1d42aaff5 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -1497,7 +1497,7 @@ sub serializeKeyAttr { foreach my $key (keys %{$$attributes{$attribute}->{'keys'}}) { my $value = $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; - push (@values, $value) if ($value ne ''); + push (@values, $value) if ($value); } foreach my $value (sort @values) { $result .= "$prefix$attribute " . escapeMeta($value) . "\n"; @@ -1532,7 +1532,7 @@ sub serializeNkAttr { && $attribute ne 'enabled' && $attribute ne 'hw_target') { my $value = $$attributes{$attribute}->{'value'}; - if ($value ne '') { + if ($value) { $result .= "$prefix$attribute " . escapeMeta($value) . "\n"; } } @@ -3140,7 +3140,7 @@ sub listDevices { my $device = shift; my $nonkey = shift; - return listDevice($device, $nonkey) if ($device ne ''); + return listDevice($device, $nonkey) if ($device); return listHandler(); } @@ -3164,7 +3164,7 @@ sub listDeviceGroups { my $group = shift; my $showall = shift; - return listDeviceGroup($group) if ($group ne ''); + return listDeviceGroup($group) if ($group); my ($groups, $errorString) = $SCST->deviceGroups(); @@ -3244,7 +3244,7 @@ sub listTargetGroups { my $indent = shift; return listDeviceGroups(undef, TRUE) if ($group eq ''); - return listTargetGroup($group, $tgroup) if ($tgroup ne ''); + return listTargetGroup($group, $tgroup) if ($tgroup); my ($tgroups, $errorString) = $SCST->targetGroups($group); @@ -3304,7 +3304,7 @@ sub listDeviceGroupDevices { my $group = shift; my $device = shift; - return listDevice($device) if ($device ne ''); + return listDevice($device) if ($device); my ($devices, $errorString) = $SCST->deviceGroupDevices($group); @@ -3332,7 +3332,7 @@ sub listDeviceGroupDevices { sub listDrivers { my $driver = shift; - return listTargets($driver, undef) if ($driver ne ''); + return listTargets($driver, undef) if ($driver); my ($drivers, $errorString) = $SCST->drivers(); @@ -3360,7 +3360,7 @@ sub listTargets { my $target = shift; my %toprint; - return listGroups($driver, $target, undef) if (($target ne '') && ($driver ne '')); + return listGroups($driver, $target, undef) if ($target and $driver); my $got_driver = defined($driver); @@ -3539,7 +3539,7 @@ sub listGroups { my $group = shift; my $found = FALSE; - if (($group ne '') && ($driver ne '') && ($target ne '')) { + if ($group and $driver and $target) { return listGroup($driver, $target, $group); } @@ -3948,7 +3948,7 @@ sub listLunAttributes { return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { - if ($group ne '') { + if ($group) { print "No such driver/target/group/lun '$driver/$target/$group/$lun' found.\n"; } else { print "No such driver/target/lun '$driver/$target/$lun' found.\n"; From 115ec5be90e1631e60b85e2a743ae3c335793724 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 13 May 2020 20:37:30 +0000 Subject: [PATCH 4/4] scripts/kernel-functions: Only apply RHEL patches on RHEL kernels git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8906 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/kernel-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kernel-functions b/scripts/kernel-functions index b3a70ada3..0a7bc0d63 100644 --- a/scripts/kernel-functions +++ b/scripts/kernel-functions @@ -512,7 +512,7 @@ index 8fa38d3e7538..f5bc4c046461 100644 EOF ;; - *) # CentOS 6.x and 7.x + 2.6.32-*|3.10.0-*) # CentOS 6.x and 7.x patch -p1 <<'EOF' --- linux-3.10.0-1127.el7/include/linux/init.h.orig 2020-05-09 20:55:48.638956513 -0700 +++ linux-3.10.0-1127.el7/include/linux/init.h 2020-05-09 20:56:46.947612445 -0700