Avoid spurious "Success" error message.

strptime(3) doesn't set errno, so when it was failing, calling perror()
meant producing messages like:

Failed to parse FAKETIME timestamp: Success

Rather than use perror(), just send the warning message directly to
stderr.

This was first reported in https://bugs.debian.org/939789
This commit is contained in:
Daniel Kahn Gillmor
2022-02-04 17:32:17 -05:00
parent b0b9432ea4
commit bc24e278ff

View File

@@ -2374,8 +2374,8 @@ static void parse_ft_string(const char *user_faked_time)
}
else
{
perror("libfaketime: In parse_ft_string(), failed to parse FAKETIME timestamp");
fprintf(stderr, "Please check specification %s with format %s\n", user_faked_time, user_faked_time_fmt);
fprintf(stderr, "libfaketime: In parse_ft_string(), failed to parse FAKETIME timestamp.\n"
"Please check specification %s with format %s\n", user_faked_time, user_faked_time_fmt);
exit(EXIT_FAILURE);
}
break;
@@ -2418,7 +2418,7 @@ static void parse_ft_string(const char *user_faked_time)
}
else
{
perror("libfaketime: In parse_ft_string(), failed to parse FAKETIME timestamp");
fprintf(stderr, "libfaketime: In parse_ft_string(), failed to parse FAKETIME timestamp.\n");
exit(EXIT_FAILURE);
}