tools/firewire: nosy-dump: guard close(fd) when reading from input file

The file descriptor fd is initialized to -1 and only opened via open()
when the --input option is not used. However, close(fd) is called
unconditionally at the end of main(), which results in close(-1) and
a spurious EBADF error when nosy-dump reads from an input file.

Guard the close() call with "if (fd >= 0)" to match the existing
conditional cleanup pattern used for the output file handle.

Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
This commit is contained in:
longlong yan 2026-08-18 10:20:34 +08:00 committed by Takashi Sakamoto
parent c03c1a1450
commit efc4506664

View File

@ -1014,7 +1014,8 @@ int main(int argc, const char *argv[])
if (output != NULL)
fclose(output);
close(fd);
if (fd >= 0)
close(fd);
poptFreeContext(con);