Bug #6134
fix result check in smp.c
Added by Richard PALO over 5 years ago.
Updated over 5 years ago.
Description
From the code
178 static void
179 smp_cmd_failed(smp_result_t result)
180 {
181 char *smp_result_str = smp_get_result(result);
182
183 if (result == 0) {
184 fatal(-5, "Command failed: Unknown result (0x%x)",
185 result);
186 } else {
187 fatal(-5, "Command failed: %s", smp_result_str);
188 }
189 }
result == 0 is clearly an erroneous check, as smp_get_result() already treats correctly
SMP_RES_FUNCTION_ACCEPTED (0x00) as "Function accepted".
perhaps it should be SMP_RES_NONE or something else
For now, perhaps best to simply check smp_result_str == NULL
diff --git a/usr/src/cmd/scsi/smp/common/smp.c b/usr/src/cmd/scsi/smp/common/smp.c
index 67155a5..27d4f2d 100644
--- a/usr/src/cmd/scsi/smp/common/smp.c
+++ b/usr/src/cmd/scsi/smp/common/smp.c
@@ -180,7 +180,7 @@ smp_cmd_failed(smp_result_t result)
{
char *smp_result_str = smp_get_result(result);
- if (result == NULL) {
+ if (smp_result_str == NULL) {
fatal(-5, "Command failed: Unknown result (0x%x)",
result);
} else {
- Subject changed from anomalie in usr/src/cmd/scsi/smp/common/smp.c to fix result check in smp.c
- Difficulty changed from Medium to Bite-size
- Status changed from New to Closed
- % Done changed from 0 to 100
git commit 24f5a37652e188ebdcdd6da454511686935025df
commit 24f5a37652e188ebdcdd6da454511686935025df
Author: Richard PALO <richard@NetBSD.org>
Date: 2015-09-20T22:09:48.000Z
6134 fix result check in smp.c
Reviewed by: Josef Sipek <jeffpc@josefsipek.net>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Also available in: Atom
PDF