Fix maxavrocheck path processing

A null path could be given if realpath failed to resolve the name. This
hides the actual reason of the failure making it harder to resolve it.
This commit is contained in:
Markus Mäkelä 2019-06-11 08:32:28 +03:00
parent 5adc8fa5bd
commit ce3d7acf2d
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -120,8 +120,7 @@ int check_file(const char* filename)
return rval;
}
static struct option long_options[] =
{
static struct option long_options[] = {
{"verbose", no_argument, 0, 'v'},
{"dump", no_argument, 0, 'd'},
{"from", no_argument, 0, 'f'},
@ -170,10 +169,14 @@ int main(int argc, char** argv)
}
int rval = 0;
char pathbuf[PATH_MAX + 1];
for (int i = optind; i < argc; i++)
{
if (check_file(realpath(argv[i], pathbuf)))
char pathbuf[PATH_MAX + 1];
snprintf(pathbuf, sizeof(pathbuf), "%s", argv[i]);
realpath(argv[i], pathbuf);
if (check_file(pathbuf))
{
fprintf(stderr, "Failed to process file: %s\n", argv[i]);
rval = 1;