[patch] fix nonsense errno code in os_linux.cpp

[email protected] (Yuriy M. Kaminskiy) Thu, 14 Apr 2016 02:38:16 +0300
Newsgroups gmane.linux.utilities.smartmontools
Message-ID <[email protected]>
I noticed strange code in os_linux.cpp, like this:

+    if (ioctl(get_fd(), HDIO_DRIVE_TASKFILE, task)) {
+      if (errno==-EINVAL)

I don't think this can work as expected (fortunately, it seems it is only in
obsolete /dev/hda support, and only used for generating "user-friendly"
message on error path). Patch attached.

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z

_______________________________________________
Smartmontools-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/smartmontools-support
os-linux-fix-errno-handling.patch (text/x-diff, 796 B)
Index: os_linux.cpp
===================================================================
--- os_linux.cpp	(revision 4292)
+++ os_linux.cpp	(working copy)
@@ -380,7 +380,7 @@
     memcpy(task+sizeof(ide_task_request_t), data, 512);
 
     if (ioctl(get_fd(), HDIO_DRIVE_TASKFILE, task)) {
-      if (errno==-EINVAL)
+      if (errno==EINVAL)
         pout("Kernel lacks HDIO_DRIVE_TASKFILE support; compile kernel with CONFIG_IDE_TASKFILE_IO set\n");
       return -1;
     }
@@ -406,7 +406,7 @@
     buff[5]=normal_hi;
 
     if (ioctl(get_fd(), HDIO_DRIVE_TASK, buff)) {
-      if (errno==-EINVAL) {
+      if (errno==EINVAL) {
         pout("Error SMART Status command via HDIO_DRIVE_TASK failed");
         pout("Rebuild older linux 2.2 kernels with HDIO_DRIVE_TASK support added\n");
       }