From 4aeb5275d2e8c781756f727ec71c3ae8398fb0fe Mon Sep 17 00:00:00 2001 From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Tue, 15 Oct 2002 08:58:41 +0000 Subject: [PATCH] Replaced magic number by symbolic macro git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@50 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- sm5/VERSION | 2 +- sm5/atacmds.c | 34 ++++++++++++++++------------------ sm5/atacmds.cpp | 34 ++++++++++++++++------------------ sm5/smartmontools.spec | 2 +- 4 files changed, 34 insertions(+), 38 deletions(-) diff --git a/sm5/VERSION b/sm5/VERSION index 45a4fb75d..ec635144f 100644 --- a/sm5/VERSION +++ b/sm5/VERSION @@ -1 +1 @@ -8 +9 diff --git a/sm5/atacmds.c b/sm5/atacmds.c index f70515916..bc575d917 100644 --- a/sm5/atacmds.c +++ b/sm5/atacmds.c @@ -1,4 +1,4 @@ -// $Id: atacmds.c,v 1.5 2002/10/14 15:26:05 ballen4705 Exp $ +// $Id: atacmds.c,v 1.6 2002/10/15 08:58:40 ballen4705 Exp $ /* * atacmds.c * @@ -486,22 +486,20 @@ int isSupportSelfTest (struct ata_smart_values data) } -int ataCheckSmart ( struct ata_smart_values data, struct ata_smart_thresholds thresholds) -{ - int i; +// Loop over all valid attributes. If they are prefailure attributes +// and are below the threshold value, then return the index of the +// lowest failing attribute. Return 0 if all prefailure attributes +// are in bounds. +int ataCheckSmart (struct ata_smart_values data, struct ata_smart_thresholds thresholds){ + int i; - for ( i = 0 ; i < 30 ; i++ ) - { - if ( (data.vendor_attributes[i].id !=0) && - (thresholds.thres_entries[i].id != 0) && - (data.vendor_attributes[i].status.flag.prefailure) && - (data.vendor_attributes[i].current < - thresholds.thres_entries[i].threshold) && - (thresholds.thres_entries[i].threshold != 0xFE) ) - { - return i; - } - } - - return 0; + for (i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++){ + if (data.vendor_attributes[i].id && + thresholds.thres_entries[i].id && + data.vendor_attributes[i].status.flag.prefailure && + (data.vendor_attributes[i].current < thresholds.thres_entries[i].threshold) && + (thresholds.thres_entries[i].threshold != 0xFE)) + return i; + } + return 0; } diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index 241cf8ee8..8ab782193 100644 --- a/sm5/atacmds.cpp +++ b/sm5/atacmds.cpp @@ -1,4 +1,4 @@ -// $Id: atacmds.cpp,v 1.5 2002/10/14 15:26:05 ballen4705 Exp $ +// $Id: atacmds.cpp,v 1.6 2002/10/15 08:58:40 ballen4705 Exp $ /* * atacmds.c * @@ -486,22 +486,20 @@ int isSupportSelfTest (struct ata_smart_values data) } -int ataCheckSmart ( struct ata_smart_values data, struct ata_smart_thresholds thresholds) -{ - int i; +// Loop over all valid attributes. If they are prefailure attributes +// and are below the threshold value, then return the index of the +// lowest failing attribute. Return 0 if all prefailure attributes +// are in bounds. +int ataCheckSmart (struct ata_smart_values data, struct ata_smart_thresholds thresholds){ + int i; - for ( i = 0 ; i < 30 ; i++ ) - { - if ( (data.vendor_attributes[i].id !=0) && - (thresholds.thres_entries[i].id != 0) && - (data.vendor_attributes[i].status.flag.prefailure) && - (data.vendor_attributes[i].current < - thresholds.thres_entries[i].threshold) && - (thresholds.thres_entries[i].threshold != 0xFE) ) - { - return i; - } - } - - return 0; + for (i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++){ + if (data.vendor_attributes[i].id && + thresholds.thres_entries[i].id && + data.vendor_attributes[i].status.flag.prefailure && + (data.vendor_attributes[i].current < thresholds.thres_entries[i].threshold) && + (thresholds.thres_entries[i].threshold != 0xFE)) + return i; + } + return 0; } diff --git a/sm5/smartmontools.spec b/sm5/smartmontools.spec index 1933de0a1..fb15aa7a8 100644 --- a/sm5/smartmontools.spec +++ b/sm5/smartmontools.spec @@ -1,4 +1,4 @@ -Release: 7 +Release: 8 Summary: SMARTmontools - for monitoring S.M.A.R.T. disks and devices Name: smartmontools Version: 5.0 -- GitLab