From 8d8380554f3eea4ff99acbe017874003160c08b7 Mon Sep 17 00:00:00 2001
From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Tue, 21 Jul 2009 19:23:20 +0000
Subject: [PATCH] smartctl: Limit default number of printed entries for '-l
 xerror' to 8, for '-l xselftest' to 25.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2854 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 smartmontools/CHANGELOG     |  3 +++
 smartmontools/smartctl.8.in | 11 ++++++-----
 smartmontools/smartctl.cpp  | 10 ++++++----
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG
index bd5469800..75c203eef 100644
--- a/smartmontools/CHANGELOG
+++ b/smartmontools/CHANGELOG
@@ -42,6 +42,9 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [CF] smartctl: Limit default number of printed entries for
+       '-l xerror' to 8, for '-l xselftest' to 25.
+
   [CF] smartctl: Fix number of entries in '-l xselftest' output.
 
   [CF] Add USB IDs of a SunplusIT bridge, three WD drives, and an
diff --git a/smartmontools/smartctl.8.in b/smartmontools/smartctl.8.in
index 0d05ce8c4..d9cf68b1f 100644
--- a/smartmontools/smartctl.8.in
+++ b/smartmontools/smartctl.8.in
@@ -853,10 +853,11 @@ it provides sufficient space to log the contents of the 48-bit
 LBA register set introduced with ATA-6.  It also supports logs
 with more than one sector.  Each sector holds up to 4 log entries.
 The actual number of log sectors is vendor specific, typical values
-are 2 (Samsung), 5 (Seagate) or 6 (WD).
+for HDD are 2 (Samsung), 5 (Seagate) or 6 (WD). Some recent SSD devices
+have much larger error logs.
 
-If the optional parameter NUM is specified, only the NUM most
-recent log entries are printed.  Otherwise, all entries are printed.
+Only the 8 most recent error log entries are printed by default.
+This number can be changed by the optional parameter NUM.
 
 If ',error' is appended and the Extended Comprehensive SMART error
 log is not supported, the Summary SMART self-test log is printed.
@@ -909,8 +910,8 @@ and logs with more than one sector.  Each sector holds up to 19 log
 entries. The actual number of log sectors is vendor specific, typical
 values are 1 (Seagate) or 2 (Samsung).
 
-If the optional parameter NUM is specified, only the NUM most
-recent log entries are printed.  Otherwise, all entries are printed.
+Only the 25 most recent log entries are printed by default. This number
+can be changed by the optional parameter NUM.
 
 If ',selftest' is appended and the Extended SMART self-test log is not
 supported, the old SMART self-test log is printed.
diff --git a/smartmontools/smartctl.cpp b/smartmontools/smartctl.cpp
index c49573ba1..589ef1c57 100644
--- a/smartmontools/smartctl.cpp
+++ b/smartmontools/smartctl.cpp
@@ -443,7 +443,7 @@ const char * parse_options(int argc, char** argv,
 
       } else if (!strncmp(optarg, "xerror", sizeof("xerror")-1)) {
         int n1 = -1, n2 = -1, len = strlen(optarg);
-        unsigned val = ~0U;
+        unsigned val = 8;
         sscanf(optarg, "xerror%n,error%n", &n1, &n2);
         if (!(n1 == len || n2 == len)) {
           n1 = n2 = -1;
@@ -458,7 +458,7 @@ const char * parse_options(int argc, char** argv,
 
       } else if (!strncmp(optarg, "xselftest", sizeof("xselftest")-1)) {
         int n1 = -1, n2 = -1, len = strlen(optarg);
-        unsigned val = ~0U;
+        unsigned val = 25;
         sscanf(optarg, "xselftest%n,selftest%n", &n1, &n2);
         if (!(n1 == len || n2 == len)) {
           n1 = n2 = -1;
@@ -522,8 +522,10 @@ const char * parse_options(int argc, char** argv,
       ataopts.smart_check_status   = scsiopts.smart_check_status  = true;
       ataopts.smart_general_values = true;
       ataopts.smart_vendor_attrib  = scsiopts.smart_vendor_attrib = true;
-      ataopts.smart_ext_error_log  = ataopts.smart_ext_selftest_log = ~0U;
-      ataopts.retry_error_log      = ataopts.retry_selftest_log = true;
+      ataopts.smart_ext_error_log  = 8;
+      ataopts.retry_error_log      = true;
+      ataopts.smart_ext_selftest_log = 25;
+      ataopts.retry_selftest_log   = true;
       scsiopts.smart_error_log     = scsiopts.smart_selftest_log    = true;
       ataopts.smart_selective_selftest_log = true;
       ataopts.smart_logdir = ataopts.gp_logdir = true;
-- 
GitLab