In writing arithmetic comparisons, use "<" and "<=" rather than
">" and ">=". For some justification, read this:
http://thread.gmane.org/gmane.comp.version-control.git/3903/focus=4126
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
&rangecomp);
/* Sort backups */
&rangecomp);
/* Sort backups */
qsort(backups, (size_t) num_backups, sizeof(long int),
&intcomp);
}
qsort(backups, (size_t) num_backups, sizeof(long int),
&intcomp);
}
/* Walk through ranges */
for (k = 0; k < num_ranges; k++) {
/* Count IPs in use */
/* Walk through ranges */
for (k = 0; k < num_ranges; k++) {
/* Count IPs in use */
- for (; range_p->last_ip > leases[i]
+ for (; leases[i] < range_p->last_ip
&& (unsigned long) i < num_leases; i++) {
&& (unsigned long) i < num_leases; i++) {
- if (range_p->first_ip > leases[i]) {
+ if (leases[i] < range_p->first_ip) {
continue;
}
/* IP with in range */
continue;
}
/* IP with in range */
}
/* Count touched IPs */
}
/* Count touched IPs */
- for (; range_p->last_ip > touches[j]
+ for (; touches[j] < range_p->last_ip
&& (unsigned long) j < num_touches; j++) {
&& (unsigned long) j < num_touches; j++) {
- if (range_p->first_ip > touches[j]) {
+ if (touches[j] < range_p->first_ip) {
continue;
}
/* IP with in range */
continue;
}
/* IP with in range */
- if (num_backups > 0) {
- for (; range_p->last_ip > backups[m]
+ if (0 < num_backups) {
+ for (; backups[m] < range_p->last_ip
&& (unsigned long) m < num_touches; m++) {
&& (unsigned long) m < num_touches; m++) {
- if (range_p->first_ip > touches[m]) {
+ if (touches[m] < range_p->first_ip) {
continue;
}
/* IP with in range */
continue;
}
/* IP with in range */
/* Output sorting option */
if (optarg != NULL) {
sorts = strlen(optarg);
/* Output sorting option */
if (optarg != NULL) {
sorts = strlen(optarg);
eprintf
("main: only 5 first sort orders will be used");
strncpy(config.sort, optarg,
eprintf
("main: only 5 first sort orders will be used");
strncpy(config.sort, optarg,
-** Copyright (C) 2006- Sami Kerola < >
+** Copyright (C) 2006- Sami Kerola <kerolasa@iki.fi>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
- if ((num_leases > leasesmallocsize) ||
- (num_touches > touchesmallocsize) ||
- (num_backups > backupsmallocsize)) {
+ if ((leasesmallocsize < num_leases) ||
+ (touchesmallocsize < num_touches) ||
+ (backupsmallocsize < num_backups)) {
printf("WARNING: running out of memory\n");
printf("\tlease/touch/backup = %lu/%lu/%lu\n",
leasesmallocsize, touchesmallocsize,
printf("WARNING: running out of memory\n");
printf("\tlease/touch/backup = %lu/%lu/%lu\n",
leasesmallocsize, touchesmallocsize,
i++;
/* Long word which is almost causing overflow. Not any of words
* this program is looking for are this long. */
i++;
/* Long word which is almost causing overflow. Not any of words
* this program is looking for are this long. */
newclause = false;
i = 0;
continue;
newclause = false;
i = 0;
continue;
range_p->backups = 0;
range_p->shared_net = shared_p;
num_ranges++;
range_p->backups = 0;
range_p->shared_net = shared_p;
num_ranges++;
- if (num_ranges > RANGES) {
+ if (RANGES < num_ranges) {
eprintf
("parse_config: Range space full! Increase RANGES and recompile.");
exit(EXIT_FAILURE);
eprintf
("parse_config: Range space full! Increase RANGES and recompile.");
exit(EXIT_FAILURE);
/* printf ("include file: %s\n", word); */
argument = 0;
next_free_shared_name =
/* printf ("include file: %s\n", word); */
argument = 0;
next_free_shared_name =
- parse_config(false, word, current_shared_name,
+ parse_config(false, word,
+ current_shared_name,
next_free_shared_name,
shared_p);
newclause = true;
next_free_shared_name,
shared_p);
newclause = true;
fprintf
(outfile,
"shared net name first ip last ip max cur percent touch t+c t+c perc");
fprintf
(outfile,
"shared net name first ip last ip max cur percent touch t+c t+c perc");
fprintf(outfile, " bu bu perc");
}
fprintf(outfile, "\n");
fprintf(outfile, " bu bu perc");
}
fprintf(outfile, "\n");
range_p->count)) /
(range_p->last_ip - range_p->first_ip -
1));
range_p->count)) /
(range_p->last_ip - range_p->first_ip -
1));
fprintf(outfile, "%7lu %8.3f",
range_p->backups,
(float) (100 * range_p->backups) /
fprintf(outfile, "%7lu %8.3f",
range_p->backups,
(float) (100 * range_p->backups) /
fprintf(outfile, "Shared networks:\n");
fprintf(outfile,
"name max cur percent touch t+c t+c perc");
fprintf(outfile, "Shared networks:\n");
fprintf(outfile,
"name max cur percent touch t+c t+c perc");
fprintf(outfile, " bu bu perc");
}
fprintf(outfile, "\n");
fprintf(outfile, " bu bu perc");
}
fprintf(outfile, "\n");
(shared_p->touched +
shared_p->used)) /
shared_p->available);
(shared_p->touched +
shared_p->used)) /
shared_p->available);
fprintf(outfile, "%7lu %8.3f",
shared_p->backups,
(float) (100 * shared_p->backups) /
fprintf(outfile, "%7lu %8.3f",
shared_p->backups,
(float) (100 * shared_p->backups) /
fprintf(outfile,
"name max cur percent touch t+c t+c perc");
fprintf(outfile,
"name max cur percent touch t+c t+c perc");
fprintf(outfile, " bu bu perc");
}
fprintf(outfile, "\n");
fprintf(outfile, " bu bu perc");
}
fprintf(outfile, "\n");
shared_networks->used)) /
shared_networks->available);
shared_networks->used)) /
shared_networks->available);
fprintf(outfile, "%7lu %8.3f",
shared_networks->backups,
(float) (100 * shared_networks->backups) /
fprintf(outfile, "%7lu %8.3f",
shared_networks->backups,
(float) (100 * shared_networks->backups) /
output_line(outfile, "th", "ralign", "touch");
output_line(outfile, "th", "ralign", "t+c");
output_line(outfile, "th", "ralign", "t+c perc");
output_line(outfile, "th", "ralign", "touch");
output_line(outfile, "th", "ralign", "t+c");
output_line(outfile, "th", "ralign", "t+c perc");
output_line(outfile, "th", "ralign", "bu");
output_line(outfile, "th", "ralign", "bu perc");
}
output_line(outfile, "th", "ralign", "bu");
output_line(outfile, "th", "ralign", "bu perc");
}
range_p->count)) /
(range_p->last_ip -
range_p->first_ip - 1));
range_p->count)) /
(range_p->last_ip -
range_p->first_ip - 1));
output_long(outfile, "td",
range_p->backups);
output_float(outfile, "td",
output_long(outfile, "td",
range_p->backups);
output_float(outfile, "td",
output_line(outfile, "th", "ralign", "touch");
output_line(outfile, "th", "ralign", "t+c");
output_line(outfile, "th", "ralign", "t+c perc");
output_line(outfile, "th", "ralign", "touch");
output_line(outfile, "th", "ralign", "t+c");
output_line(outfile, "th", "ralign", "t+c perc");
output_line(outfile, "th", "ralign", "bu");
output_line(outfile, "th", "ralign", "bu perc");
}
output_line(outfile, "th", "ralign", "bu");
output_line(outfile, "th", "ralign", "bu perc");
}
(shared_p->touched +
shared_p->used)) /
shared_p->available);
(shared_p->touched +
shared_p->used)) /
shared_p->available);
output_long(outfile, "td",
shared_p->backups);
output_float(outfile, "td",
output_long(outfile, "td",
shared_p->backups);
output_float(outfile, "td",
output_line(outfile, "th", "ralign", "touch");
output_line(outfile, "th", "ralign", "t+c");
output_line(outfile, "th", "ralign", "t+c perc");
output_line(outfile, "th", "ralign", "touch");
output_line(outfile, "th", "ralign", "t+c");
output_line(outfile, "th", "ralign", "t+c perc");
output_line(outfile, "th", "ralign", "bu");
output_line(outfile, "th", "ralign", "bu perc");
}
output_line(outfile, "th", "ralign", "bu");
output_line(outfile, "th", "ralign", "bu perc");
}
(shared_networks->touched +
shared_networks->used)) /
shared_networks->available);
(shared_networks->touched +
shared_networks->used)) /
shared_networks->available);
output_long(outfile, "td",
shared_networks->backups);
output_float(outfile, "td",
output_long(outfile, "td",
shared_networks->backups);
output_float(outfile, "td",
fprintf
(outfile,
"\"shared net name\",\"first ip\",\"last ip\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
fprintf
(outfile,
"\"shared net name\",\"first ip\",\"last ip\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
fprintf(outfile, ",\"bu\",\"bu perc\"");
}
fprintf(outfile, "\n");
fprintf(outfile, ",\"bu\",\"bu perc\"");
}
fprintf(outfile, "\n");
range_p->count)) /
(range_p->last_ip - range_p->first_ip -
1));
range_p->count)) /
(range_p->last_ip - range_p->first_ip -
1));
fprintf(outfile, ",\"%lu\",\"%.3f\"",
range_p->backups,
(float) (100 * range_p->backups) /
fprintf(outfile, ",\"%lu\",\"%.3f\"",
range_p->backups,
(float) (100 * range_p->backups) /
fprintf(outfile, "\"Shared networks:\"\n");
fprintf(outfile,
"\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
fprintf(outfile, "\"Shared networks:\"\n");
fprintf(outfile,
"\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
fprintf(outfile, ",\"bu\",\"bu perc\"");
}
fprintf(outfile, "\n");
fprintf(outfile, ",\"bu\",\"bu perc\"");
}
fprintf(outfile, "\n");
(shared_p->touched +
shared_p->used)) /
shared_p->available);
(shared_p->touched +
shared_p->used)) /
shared_p->available);
fprintf(outfile, ",\"%lu\",\"%.3f\"",
shared_p->backups,
(float) (100 * shared_p->backups) /
fprintf(outfile, ",\"%lu\",\"%.3f\"",
shared_p->backups,
(float) (100 * shared_p->backups) /
fprintf(outfile, "\"Sum of all ranges:\"\n");
fprintf(outfile,
"\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
fprintf(outfile, "\"Sum of all ranges:\"\n");
fprintf(outfile,
"\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
fprintf(outfile, ",\"bu\",\"bu perc\"");
}
fprintf(outfile, "\n");
fprintf(outfile, ",\"bu\",\"bu perc\"");
}
fprintf(outfile, "\n");
(shared_networks->touched +
shared_networks->used)) /
shared_networks->available);
(shared_networks->touched +
shared_networks->used)) /
shared_networks->available);
fprintf(outfile, "%7lu %8.3f",
shared_networks->backups,
(float) (100 * shared_networks->backups) /
fprintf(outfile, "%7lu %8.3f",
shared_networks->backups,
(float) (100 * shared_networks->backups) /
ret =
strcmp(left->shared_net->name,
right->shared_net->name);
ret =
strcmp(left->shared_net->name,
right->shared_net->name);
return (0);
} else if (ret < 0) {
return (1);
return (0);
} else if (ret < 0) {
return (1);
if (size < MIN_MERGE_SIZE) {
for (left = 0; left < size; left++) {
hold = *(orig + left);
if (size < MIN_MERGE_SIZE) {
for (left = 0; left < size; left++) {
hold = *(orig + left);
- for (right = left - 1; right >= 0; right--) {
+ for (right = left - 1; 0 <= right; right--) {
if (get_order((orig + right), &hold)) {
break;
}
if (get_order((orig + right), &hold)) {
break;
}