Date: 26 Apr 2001 14:23:49 +0200 From: Dag-Erling Smorgrav <des@ofug.org> To: hackers@freebsd.org Subject: gcc -O bug Message-ID: <xzplmonx31m.fsf@flood.ping.uio.no>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
The warning about "time" being possibly uninitialized is safe to
ignore; this can only happen if the log is empty.
The C source and a truncated log that reproduces the bug are attached
at the end of this message.
des@aes ~/ts/projects/MGW/misc% uname -a
FreeBSD aes.thinksec.com 5.0-CURRENT FreeBSD 5.0-CURRENT #23: Fri Apr 13 00:35:50 CEST 2001 des@aes.thinksec.com:/usr/src/sys/compile/AES i386
des@aes ~/ts/projects/MGW/misc% gcc --version
2.95.3
des@aes ~/ts/projects/MGW/misc% cc -Wall -pedantic logalyze.c
logalyze.c: In function `main':
logalyze.c:28: warning: unused variable `j'
des@aes ~/ts/projects/MGW/misc% head -10000 ../ldalog | ./a.out
9412 messages accepted, 588 rejected
log spans 6.98 hours
average throughput: 1347.73 msg/h
Breakdown per hour:
00 | 0
01 | 0
02 | 0
03 | 0
04 | 0
05 | 0
06 | 0
07 | 0
08 | 0
09 | 0
10 | 0
11 | 0
12 | 0
13 | 0
14 | 0
15 | 0
16 |#################### 1009
17 |############################################### 2329
18 |########################## 1274
19 |############## 712
20 |################ 816
21 |################################################## 2446
22 |########## 500
23 |###### 326
des@aes ~/ts/projects/MGW/misc% cc -O -Wall -pedantic logalyze.c
logalyze.c: In function `main':
logalyze.c:28: warning: unused variable `j'
logalyze.c:27: warning: `time' might be used uninitialized in this function
des@aes ~/ts/projects/MGW/misc% head -10000 ../ldalog | ./a.out
9412 messages accepted, 588 rejected
log spans 7.98 hours
average throughput: 1178.92 msg/h
Breakdown per hour:
00 | 0
01 | 0
02 | 0
03 | 0
04 | 0
05 | 0
06 | 0
07 | 0
08 | 0
09 | 0
10 | 0
11 | 0
12 | 0
13 | 0
14 | 0
15 | 1
16 |#################### 1008
17 |############################################### 2329
18 |########################## 1274
19 |############## 712
20 |################ 816
21 |################################################## 2446
22 |########## 500
23 |###### 326
des@aes ~/ts/projects/MGW/misc% head -10000 ../ldalog | ./logalyze.pl
9412 messages accepted, 588 rejected
log spans 6.98 hours
average throughput: 1347.73 msg/h
Breakdown per hour:
00 | 0
01 | 0
02 | 0
03 | 0
04 | 0
05 | 0
06 | 0
07 | 0
08 | 0
09 | 0
10 | 0
11 | 0
12 | 0
13 | 0
14 | 0
15 | 0
16 |#################### 1009
17 |############################################### 2329
18 |########################## 1274
19 |############## 712
20 |################ 816
21 |################################################## 2446
22 |########## 500
23 |###### 326
DES
--
Dag-Erling Smorgrav - des@ofug.org
[-- Attachment #2 --]
/*
* Copyright (c) 2001 ThinkSec AS. All rights reserved.
*
* $ThinkSec$
*/
#include <err.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
static int accepted, rejected;
static time_t first, last;
static double duration;
static int hour[24];
static int week[7][25];
static const char hashes[] =
"##################################################!";
int
main(void)
{
char *line;
size_t len;
struct tm tm;
time_t time;
int i, j, max;
double scale;
setbuf(stdout, NULL);
while ((line = fgetln(stdin, &len)) != NULL) {
if (len < 20 || line[4] != '-' || line[7] != '-' || line[10] != '-'
|| line[13] != ':' || line[16] != ':' || line[19] != ':') {
warn("malformed line: %.*s\n", (int)len, line);
continue;
}
if (line[20] == '-') {
++rejected;
continue;
}
tm.tm_year = atoi(line) - 1900;
tm.tm_mon = atoi(line + 5) - 1;
tm.tm_mday = atoi(line + 8);
tm.tm_hour = atoi(line + 11);
tm.tm_min = atoi(line + 14);
tm.tm_sec = atoi(line + 17);
time = mktime(&tm);
if (!first)
first = time;
++hour[tm.tm_hour];
++week[tm.tm_wday][tm.tm_hour];
++week[tm.tm_wday][24];
if (++accepted % 1000 == 0)
printf("\r%d", accepted);
}
last = time;
printf("\r%d messages accepted, %d rejected\n", accepted, rejected);
duration = (last - first + 1) / 3600.0;
printf("log spans %.2f hours\n", duration);
printf("average throughput: %.2f msg/h\n", accepted / duration);
printf("\nBreakdown per hour:\n\n");
for (i = max = 0; i < 24; ++i)
if (hour[i] > max)
max = hour[i];
scale = max / 50.0;
for (i = 0; i < 24; ++i) {
printf("%02d |%.*s %d\n", i, (int)(hour[i] / scale), hashes, hour[i]);
}
exit(0);
}
[-- Attachment #3 --]
2001-01-05-16:27:23:N
2001-01-05-16:27:24:N
2001-01-05-16:27:25:N
2001-01-05-16:27:25:N
2001-01-05-16:27:25:N
2001-01-05-16:27:26:N
2001-01-05-16:27:26:N
2001-01-05-16:27:26:N
2001-01-05-16:27:27:N
2001-01-05-16:27:28:N
2001-01-05-16:27:28:N
2001-01-05-16:27:29:N
2001-01-05-16:27:29:N
2001-01-05-16:27:29:N
2001-01-05-16:27:31:N
2001-01-05-16:27:32:N
2001-01-05-16:27:32:N
2001-01-05-16:27:32:N
2001-01-05-16:27:33:N
2001-01-05-16:27:33:N
2001-01-05-16:27:34:N
2001-01-05-16:27:34:N
2001-01-05-16:27:34:N
2001-01-05-16:27:35:N
2001-01-05-16:27:35:N
2001-01-05-16:27:35:N
2001-01-05-16:27:36:N
2001-01-05-16:27:37:N
2001-01-05-16:27:38:N
2001-01-05-16:27:39:N
2001-01-05-16:27:39:N
2001-01-05-16:27:39:N
2001-01-05-16:27:40:N
2001-01-05-16:27:41:-N
2001-01-05-16:27:41:N
2001-01-05-16:27:41:N
2001-01-05-16:27:41:-N
2001-01-05-16:27:42:-N
2001-01-05-16:27:43:N
2001-01-05-16:27:43:-N
2001-01-05-16:27:43:N
2001-01-05-16:27:44:-N
2001-01-05-16:27:44:-N
2001-01-05-16:27:45:N
2001-01-05-16:27:45:N
2001-01-05-16:27:47:N
2001-01-05-16:27:47:N
2001-01-05-16:27:48:N
2001-01-05-16:27:48:N
2001-01-05-16:27:49:N
2001-01-05-16:27:49:N
2001-01-05-16:27:50:N
2001-01-05-16:27:50:N
2001-01-05-16:27:50:N
2001-01-05-16:27:51:N
2001-01-05-16:27:52:-N
2001-01-05-16:27:52:N
2001-01-05-16:27:52:N
2001-01-05-16:27:52:N
2001-01-05-16:27:53:N
2001-01-05-16:27:53:N
2001-01-05-16:27:53:N
2001-01-05-16:27:54:-N
2001-01-05-16:27:55:N
2001-01-05-16:27:55:N
2001-01-05-16:27:55:-N
2001-01-05-16:27:56:N
2001-01-05-16:27:57:N
2001-01-05-16:27:58:-N
2001-01-05-16:27:58:N
2001-01-05-16:27:58:N
2001-01-05-16:27:59:N
2001-01-05-16:27:59:N
2001-01-05-16:27:59:N
2001-01-05-16:28:00:N
2001-01-05-16:28:00:N
2001-01-05-16:28:00:N
2001-01-05-16:28:01:N
2001-01-05-16:28:02:N
2001-01-05-16:28:02:N
2001-01-05-16:28:02:N
2001-01-05-16:28:03:N
2001-01-05-16:28:03:N
2001-01-05-16:28:04:N
2001-01-05-16:28:04:N
2001-01-05-16:28:04:N
2001-01-05-16:28:05:N
2001-01-05-16:28:05:N
2001-01-05-16:28:05:N
2001-01-05-16:28:06:-N
2001-01-05-16:28:06:N
2001-01-05-16:28:06:N
2001-01-05-16:28:07:-N
2001-01-05-16:28:07:N
2001-01-05-16:28:08:N
2001-01-05-16:28:08:N
2001-01-05-16:28:09:N
2001-01-05-16:28:09:N
2001-01-05-16:28:09:N
2001-01-05-16:28:10:N
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzplmonx31m.fsf>
