# HG changeset patch # User Matti Hamalainen # Date 1511305481 -7200 # Node ID ed04fb6da07ceb0426c6cbc3eb836cced83e3a35 # Parent cb627176298dcd2726aa6cdc74bbbe979b6adafc Get rid of direct 'errno' usage. diff -r cb627176298d -r ed04fb6da07c tools/objlink.c --- a/tools/objlink.c Wed Nov 15 07:51:43 2017 +0200 +++ b/tools/objlink.c Wed Nov 22 01:04:41 2017 +0200 @@ -5,7 +5,6 @@ * * Please read file 'COPYING' for information on license and distribution. */ -#include #include "dmlib.h" #include "dmargs.h" #include "dmfile.h" @@ -522,23 +521,27 @@ // Open the input file if ((f = fopen(filename, "rb")) == NULL) { - dmErrorMsg("Error opening input file '%s' (%s).\n", - filename, strerror(errno)); + int err = dmGetErrno(); + dmErrorMsg("Error opening input file '%s' #%d: %s.\n", + filename, err, dmErrorStr(err)); return 1; } // Get filesize if ((dataSize = dmGetFileSize(f) - 2) < 0) { - dmErrorMsg("Error getting file size for '%s'.\n", filename); + int err = dmGetErrno(); + dmErrorMsg("Error getting file size for '%s' #%d: %s.\n", + filename, err, dmErrorStr(err)); return 6; } // Get loading address if (!dm_fread_le16(f, &tmpAddr)) { - dmErrorMsg("Error reading input file '%s' (%s).\n", - filename, strerror(errno)); + int err = dmGetErrno(); + dmErrorMsg("Error reading input file '%s' #%d: %s.\n", + filename, err, dmErrorStr(err)); return 2; } @@ -558,8 +561,9 @@ // Load data if (fread(&memory[loadAddr], dataSize, 1, f) < 1) { - dmPrint(1, " .. Error: %s.\n", - strerror(errno)); + int err = dmGetErrno(); + dmPrint(1, " .. Error #%d: %s.\n", + err, dmErrorStr(err)); return 4; } @@ -580,8 +584,9 @@ // Open the input file if ((f = fopen(filename, "rb")) == NULL) { - dmErrorMsg("Error opening input file '%s' (%s).\n", - filename, strerror(errno)); + int err = dmGetErrno(); + dmErrorMsg("Error opening input file '%s' #%d: %s.\n", + filename, err, dmErrorStr(err)); return 1; } @@ -606,8 +611,9 @@ // Load data if (fread(&memory[destAddr], dataSize, 1, f) < 1) { - dmPrint(1, " .. Error: %s.\n", - strerror(errno)); + int err = dmGetErrno(); + dmPrint(1, " .. Error #%d: %s.\n", + err, dmErrorStr(err)); return 4; } @@ -906,7 +912,9 @@ dmMsg(1, "Writing linkfile to '%s'\n", optLinkFileName); if ((dfile = fopen(optLinkFileName, "wb")) == NULL) { - dmErrorMsg("Error creating file '%s' (%s).\n", optLinkFileName, strerror(errno)); + int err = dmGetErrno(); + dmErrorMsg("Error creating file '%s' #%d: %s.\n", + optLinkFileName, err, dmErrorStr(err)); exit(1); } @@ -955,7 +963,9 @@ } else if ((dfile = fopen(optDestName, "wb")) == NULL) { - dmErrorMsg("Error creating output file '%s' (%s).\n", optDestName, strerror(errno)); + int err = dmGetErrno(); + dmErrorMsg("Error creating output file '%s' #%d: %s.\n", + optDestName, err, dmErrorStr(err)); exit(1); } else @@ -981,7 +991,9 @@ // Save the data if (fwrite(&memory[startAddr], dataSize, 1, dfile) < 1) { - dmErrorMsg("Error writing to file (%s)\n", strerror(errno)); + int err = dmGetErrno(); + dmErrorMsg("Error writing to file #%d: %s.\n", + err, dmErrorStr(err)); } fclose(dfile); diff -r cb627176298d -r ed04fb6da07c tools/xm2jss.c --- a/tools/xm2jss.c Wed Nov 15 07:51:43 2017 +0200 +++ b/tools/xm2jss.c Wed Nov 22 01:04:41 2017 +0200 @@ -6,7 +6,6 @@ * Please read file 'COPYING' for information on license and distribution. */ #include -#include #include "jss.h" #include "jssmod.h" #include "jssplr.h" @@ -1249,8 +1248,9 @@ // Write output file if ((outFile = fopen(optOutFilename, "wb")) == NULL) { + int err = dmGetErrno(); dmErrorMsg("Error creating output file '%s', %d: %s\n", - optOutFilename, errno, strerror(errno)); + optOutFilename, err, dmErrorStr(err)); return 1; }