mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 12:00:31 +01:00
Util: Rewrite error message generation to avoid potential problem
The call to 'snprintf' may change the value of 'errno', which means that the 'perror' call would print a wrong error message, not the one from 'fopen'.
This commit is contained in:
committed by
Carlos R. Mafra
parent
308b9f4975
commit
d4cc033379
@@ -121,12 +121,8 @@ int main(int argc, char **argv)
|
|||||||
if (filename) {
|
if (filename) {
|
||||||
file = fopen(filename, "rb");
|
file = fopen(filename, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
char line[1024];
|
fprintf(stderr, "%s: could not open \"%s\", %s\n",
|
||||||
|
prog_name, filename, strerror(errno));
|
||||||
snprintf(line, sizeof(line),
|
|
||||||
"%s: could not open \"%s\"",
|
|
||||||
prog_name, filename);
|
|
||||||
perror(line);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user