Commit 8eace59
libnvme: propagate the error to the caller if nvme_get_log_page() fails
The nvme_get_log_page() function may return an NVMe status code on failure,
leaving the errno number set to zero.
The nvme_discovery_log() function wasn't
propagating this error information to its caller; it would just return
NULL without setting a meaningful errno value.
the NULL pointer is interpreted as an error by nvme-cli, it then tries
to print the string associated to the errno value, resulting
in a funny output:
failed to get discovery log: Success
Fix this by capturing the status code returned by
nvme_get_log_page(), converting it to an errno value using
nvme_status_to_errno(), and setting errno before returning.
Additionally, the error message has been improved to include the
NVMe status code and the log level has been raised from
LOG_INFO to LOG_ERR.
Signed-off-by: Maurizio Lombardi <[email protected]>1 parent 0bf294e commit 8eace59
1 file changed
Lines changed: 15 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1134 | 1134 | | |
1135 | 1135 | | |
1136 | 1136 | | |
| 1137 | + | |
1137 | 1138 | | |
1138 | 1139 | | |
1139 | 1140 | | |
| |||
1161 | 1162 | | |
1162 | 1163 | | |
1163 | 1164 | | |
1164 | | - | |
| 1165 | + | |
| 1166 | + | |
1165 | 1167 | | |
1166 | | - | |
1167 | | - | |
| 1168 | + | |
| 1169 | + | |
1168 | 1170 | | |
1169 | 1171 | | |
1170 | 1172 | | |
| |||
1194 | 1196 | | |
1195 | 1197 | | |
1196 | 1198 | | |
1197 | | - | |
| 1199 | + | |
| 1200 | + | |
1198 | 1201 | | |
1199 | | - | |
1200 | | - | |
| 1202 | + | |
| 1203 | + | |
1201 | 1204 | | |
1202 | 1205 | | |
1203 | 1206 | | |
| |||
1210 | 1213 | | |
1211 | 1214 | | |
1212 | 1215 | | |
1213 | | - | |
| 1216 | + | |
| 1217 | + | |
1214 | 1218 | | |
1215 | | - | |
1216 | | - | |
| 1219 | + | |
| 1220 | + | |
1217 | 1221 | | |
1218 | 1222 | | |
1219 | 1223 | | |
| |||
1234 | 1238 | | |
1235 | 1239 | | |
1236 | 1240 | | |
| 1241 | + | |
| 1242 | + | |
1237 | 1243 | | |
1238 | 1244 | | |
1239 | 1245 | | |
| |||
0 commit comments