summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cffebf4)
raw | patch | inline | side by side (parent: cffebf4)
author | Florian Forster <octo@verplant.org> | |
Wed, 15 Jul 2009 11:11:27 +0000 (13:11 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Wed, 15 Jul 2009 11:11:27 +0000 (13:11 +0200) |
src/oping.c | patch | blob | history |
diff --git a/src/oping.c b/src/oping.c
index 4f75f22be5e92d195b99c343bdf42ef460447ef8..c901223acc18826ef495a527d03f9dc4e01b558b 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
optind = read_options (argc, argv);
- if (optind >= argc && !opt_filename) {
+ if ((optind >= argc) && (opt_filename == NULL)) {
usage_exit (argv[0]);
}
else
infile = fopen(opt_filename, "r");
- if (!infile)
+ if (infile == NULL)
{
- fprintf (stderr, "Couldn't open file for hostnames: %s\n", strerror(errno));
+ fprintf (stderr, "Opening %s failed: %s\n",
+ (strcmp (opt_filename, "-") == 0)
+ ? "STDIN" : opt_filename,
+ strerror(errno));
return (1);
}
while (fgets(line, sizeof(line), infile))
{
+ /* Strip whitespace */
if (sscanf(line, "%s", host) != 1)
continue;
- if ((!*host) || (host[0] == '#'))
+ if ((host[0] == 0) || (host[0] == '#'))
continue;
if (ping_host_add(ping, host) < 0)