]> granicus.if.org Git - sysstat/blobdiff - sar.c
sa_common.c: Remove some dead code
[sysstat] / sar.c
diff --git a/sar.c b/sar.c
index 45dc1beedf8605f7801d8019dab2e64787d2cdbf..519ad65bbc7ab743aa8bf7db2ed0bc3364e614bf 100644 (file)
--- a/sar.c
+++ b/sar.c
@@ -487,20 +487,15 @@ int write_stats(int curr, int read_from_file, long *cnt, int use_tm_start,
        }
 
        /* Check time (2) */
-       if (use_tm_start && (datecmp(&rectime, &tm_start, cross_day) < 0))
-               /* it's too soon... */
-               return 0;
-
-       /* Get interval value in 1/100th of a second */
-       get_itv_value(&record_hdr[curr], &record_hdr[!curr], &itv);
-
-       /* Check time (3) */
        if (use_tm_end && (datecmp(&rectime, &tm_end, cross_day) > 0)) {
-               /* It's too late... */
+               /* End time exceeded */
                *cnt = 0;
                return 0;
        }
 
+       /* Get interval value in 1/100th of a second */
+       get_itv_value(&record_hdr[curr], &record_hdr[!curr], &itv);
+
        avg_count++;
 
        /* Test stdout */
@@ -805,8 +800,10 @@ void handle_curr_act_stats(int ifd, off_t fpos, int *curr, long *cnt, int *eosaf
 
                if (rtype != R_COMMENT) {
                        /* Read the extra fields since it's not a special record */
-                       read_file_stat_bunch(act, *curr, ifd, file_hdr.sa_act_nr, file_actlst,
-                                            endian_mismatch, arch_64, file, file_magic, UEOF_STOP);
+                       if (read_file_stat_bunch(act, *curr, ifd, file_hdr.sa_act_nr, file_actlst,
+                                                endian_mismatch, arch_64, file, file_magic, UEOF_STOP))
+                               /* Error or unexpected EOF */
+                               break;
                }
                else {
                        /* Display comment */
@@ -1050,9 +1047,12 @@ void read_stats_from_file(char from_file[])
                                 * OK: Previous record was not a special one.
                                 * So read now the extra fields.
                                 */
-                               read_file_stat_bunch(act, 0, ifd, file_hdr.sa_act_nr,
-                                                    file_actlst, endian_mismatch, arch_64,
-                                                    from_file, &file_magic, UEOF_STOP);
+                               if (read_file_stat_bunch(act, 0, ifd, file_hdr.sa_act_nr,
+                                                        file_actlst, endian_mismatch, arch_64,
+                                                        from_file, &file_magic, UEOF_STOP))
+                                       /* Possible unexpected EOF */
+                                       return;
+
                                if (sa_get_record_timestamp_struct(flags + S_F_LOCAL_TIME,
                                                                   &record_hdr[0], &rectime))
                                        /*
@@ -1138,9 +1138,11 @@ void read_stats_from_file(char from_file[])
                                        break;
 
                                if (rtype != R_COMMENT) {
-                                       read_file_stat_bunch(act, curr, ifd, file_hdr.sa_act_nr,
-                                                            file_actlst, endian_mismatch, arch_64,
-                                                            from_file, &file_magic, UEOF_STOP);
+                                       if (read_file_stat_bunch(act, curr, ifd, file_hdr.sa_act_nr,
+                                                                file_actlst, endian_mismatch, arch_64,
+                                                                from_file, &file_magic, UEOF_STOP))
+                                               /* Possible unexpected EOF */
+                                               break;
                                }
                                else {
                                        /* This was a COMMENT record: Print it */