chg: some unifiying return values

This commit is contained in:
iceman1001 2019-05-15 10:24:06 +02:00
commit 0740d14faa
6 changed files with 66 additions and 66 deletions

View file

@ -1622,7 +1622,7 @@ static int CmdLoad(const char *Cmd) {
FILE *f = fopen(filename, "r"); FILE *f = fopen(filename, "r");
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "couldn't open '%s'", filename); PrintAndLogEx(WARNING, "couldn't open '%s'", filename);
return 0; return PM3_EFILE;
} }
GraphTraceLen = 0; GraphTraceLen = 0;
@ -1649,7 +1649,7 @@ static int CmdLoad(const char *Cmd) {
setClockGrid(0, 0); setClockGrid(0, 0);
DemodBufferLen = 0; DemodBufferLen = 0;
RepaintGraphWindow(); RepaintGraphWindow();
return 0; return PM3_SUCCESS;
} }
// trim graph from the end // trim graph from the end
@ -1742,7 +1742,7 @@ static int CmdSave(const char *Cmd) {
FILE *f = fopen(filename, "w"); FILE *f = fopen(filename, "w");
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "couldn't open '%s'", filename); PrintAndLogEx(WARNING, "couldn't open '%s'", filename);
return 0; return PM3_EFILE;
} }
for (uint32_t i = 0; i < GraphTraceLen; i++) for (uint32_t i = 0; i < GraphTraceLen; i++)
@ -1752,7 +1752,7 @@ static int CmdSave(const char *Cmd) {
fclose(f); fclose(f);
PrintAndLogEx(SUCCESS, "saved to '%s'", Cmd); PrintAndLogEx(SUCCESS, "saved to '%s'", Cmd);
return 0; return PM3_SUCCESS;
} }
static int CmdScale(const char *Cmd) { static int CmdScale(const char *Cmd) {

View file

@ -275,14 +275,14 @@ static int CmdHFiClassList(const char *Cmd) {
(void)Cmd; // Cmd is not used so far (void)Cmd; // Cmd is not used so far
//PrintAndLogEx(NORMAL, "Deprecated command, use 'hf list iclass' instead"); //PrintAndLogEx(NORMAL, "Deprecated command, use 'hf list iclass' instead");
CmdTraceList("iclass"); CmdTraceList("iclass");
return 0; return PM3_SUCCESS;
} }
static int CmdHFiClassSniff(const char *Cmd) { static int CmdHFiClassSniff(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0)); char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_hf_iclass_sniff(); if (cmdp == 'h') return usage_hf_iclass_sniff();
SendCommandNG(CMD_SNIFF_ICLASS, NULL, 0); SendCommandNG(CMD_SNIFF_ICLASS, NULL, 0);
return 0; return PM3_SUCCESS;
} }
static int CmdHFiClassSim(const char *Cmd) { static int CmdHFiClassSim(const char *Cmd) {
@ -501,7 +501,7 @@ static int CmdHFiClassSim(const char *Cmd) {
break; break;
} }
} }
return 0; return PM3_SUCCESS;
} }
static int CmdHFiClassReader(const char *Cmd) { static int CmdHFiClassReader(const char *Cmd) {
@ -525,8 +525,8 @@ static int CmdHFiClassReader_Replay(const char *Cmd) {
} }
clearCommandBuffer(); clearCommandBuffer();
SendCommandOLD(CMD_READER_ICLASS_REPLAY, readerType, 0, 0, MAC, 4); SendCommandMIX(CMD_READER_ICLASS_REPLAY, readerType, 0, 0, MAC, 4);
return 0; return PM3_SUCCESS;
} }
static int CmdHFiClassELoad(const char *Cmd) { static int CmdHFiClassELoad(const char *Cmd) {
@ -547,7 +547,7 @@ static int CmdHFiClassELoad(const char *Cmd) {
FILE *f = fopen(filename, "rb"); FILE *f = fopen(filename, "rb");
if (!f) { if (!f) {
PrintAndLogEx(FAILED, "File: " _YELLOW_("%s") ": not found or locked.", filename); PrintAndLogEx(FAILED, "File: " _YELLOW_("%s") ": not found or locked.", filename);
return 1; return PM3_EFILE;
} }
// get filesize in order to malloc memory // get filesize in order to malloc memory
@ -601,14 +601,14 @@ static int CmdHFiClassELoad(const char *Cmd) {
free(dump); free(dump);
PrintAndLogEx(SUCCESS, "sent %d bytes of data to device emulator memory", bytes_sent); PrintAndLogEx(SUCCESS, "sent %d bytes of data to device emulator memory", bytes_sent);
return 0; return PM3_SUCCESS;
} }
static int readKeyfile(const char *filename, size_t len, uint8_t *buffer) { static int readKeyfile(const char *filename, size_t len, uint8_t *buffer) {
FILE *f = fopen(filename, "rb"); FILE *f = fopen(filename, "rb");
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "Failed to read from file '%s'", filename); PrintAndLogEx(FAILED, "File: " _YELLOW_("%s") ": not found or locked.", filename);
return 1; return PM3_EFILE;
} }
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
long fsize = ftell(f); long fsize = ftell(f);
@ -625,7 +625,7 @@ static int readKeyfile(const char *filename, size_t len, uint8_t *buffer) {
PrintAndLogEx(WARNING, "Warning, could only read %d bytes, expected %d", bytes_read, len); PrintAndLogEx(WARNING, "Warning, could only read %d bytes, expected %d", bytes_read, len);
return 1; return 1;
} }
return 0; return PM3_SUCCESS;
} }
static int CmdHFiClassDecrypt(const char *Cmd) { static int CmdHFiClassDecrypt(const char *Cmd) {
@ -644,8 +644,8 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
if (opt == 'f' && param_getstr(Cmd, 1, filename, sizeof(filename)) > 0) { if (opt == 'f' && param_getstr(Cmd, 1, filename, sizeof(filename)) > 0) {
f = fopen(filename, "rb"); f = fopen(filename, "rb");
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "could not find file %s", filename); PrintAndLogEx(FAILED, "File: " _YELLOW_("%s") ": not found or locked.", filename);
return 1; return PM3_EFILE;
} }
} else { } else {
return usage_hf_iclass_decrypt(); return usage_hf_iclass_decrypt();
@ -712,7 +712,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
saveFile(outfilename, ".bin", decrypted, fsize); saveFile(outfilename, ".bin", decrypted, fsize);
printIclassDumpContents(decrypted, 1, (fsize / 8), fsize); printIclassDumpContents(decrypted, 1, (fsize / 8), fsize);
free(decrypted); free(decrypted);
return 0; return PM3_SUCCESS;
} }
static int iClassEncryptBlkData(uint8_t *blkData) { static int iClassEncryptBlkData(uint8_t *blkData) {
@ -745,7 +745,7 @@ static int CmdHFiClassEncryptBlk(const char *Cmd) {
if (!iClassEncryptBlkData(blkData)) return 0; if (!iClassEncryptBlkData(blkData)) return 0;
printvar("encrypted block", blkData, 8); printvar("encrypted block", blkData, 8);
return 1; return PM3_SUCCESS;
} }
static void Calc_wb_mac(uint8_t blockno, uint8_t *data, uint8_t *div_key, uint8_t MAC[4]) { static void Calc_wb_mac(uint8_t blockno, uint8_t *data, uint8_t *div_key, uint8_t MAC[4]) {
@ -1272,8 +1272,8 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
// file handling and reading // file handling and reading
f = fopen(filename, "rb"); f = fopen(filename, "rb");
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "failed to read file '%s'", filename); PrintAndLogEx(FAILED, "File: " _YELLOW_("%s") ": not found or locked.", filename);
return 1; return PM3_EFILE;
} }
if (startblock < 5) { if (startblock < 5) {
@ -1331,7 +1331,7 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
PrintAndLogEx(WARNING, "command execute timeout"); PrintAndLogEx(WARNING, "command execute timeout");
return 0; return 0;
} }
return 1; return PM3_SUCCESS;
} }
static int ReadBlock(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite, bool rawkey, bool verbose, bool auth) { static int ReadBlock(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite, bool rawkey, bool verbose, bool auth) {
@ -1461,7 +1461,7 @@ static int CmdHFiClass_loclass(const char *Cmd) {
if (errors) PrintAndLogDevice(WARNING, "There were errors!!!"); if (errors) PrintAndLogDevice(WARNING, "There were errors!!!");
return errors; return errors;
} }
return 0; return PM3_SUCCESS;
} }
void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t endblock, size_t filesize) { void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t endblock, size_t filesize) {
@ -1520,8 +1520,8 @@ static int CmdHFiClassReadTagFile(const char *Cmd) {
// file handling and reading // file handling and reading
f = fopen(filename, "rb"); f = fopen(filename, "rb");
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "Failed to read from file '%s'", filename); PrintAndLogEx(FAILED, "File: " _YELLOW_("%s") ": not found or locked.", filename);
return 1; return PM3_EFILE;
} }
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
long fsize = ftell(f); long fsize = ftell(f);
@ -1547,7 +1547,7 @@ static int CmdHFiClassReadTagFile(const char *Cmd) {
PrintAndLogEx(NORMAL, "CSN |00| %s|\n", sprint_hex(csn, 8)); PrintAndLogEx(NORMAL, "CSN |00| %s|\n", sprint_hex(csn, 8));
printIclassDumpContents(dump, startblock, endblock, bytes_read); printIclassDumpContents(dump, startblock, endblock, bytes_read);
free(dump); free(dump);
return 0; return PM3_SUCCESS;
} }
void HFiClassCalcDivKey(uint8_t *CSN, uint8_t *KEY, uint8_t *div_key, bool elite) { void HFiClassCalcDivKey(uint8_t *CSN, uint8_t *KEY, uint8_t *div_key, bool elite) {
@ -1670,15 +1670,15 @@ static int CmdHFiClassCalcNewKey(const char *Cmd) {
return 0; return 0;
HFiClassCalcNewKey(CSN, OLDKEY, NEWKEY, xor_div_key, elite, oldElite, true); HFiClassCalcNewKey(CSN, OLDKEY, NEWKEY, xor_div_key, elite, oldElite, true);
return 0; return PM3_SUCCESS;
} }
static int loadKeys(char *filename) { static int loadKeys(char *filename) {
FILE *f; FILE *f;
f = fopen(filename, "rb"); f = fopen(filename, "rb");
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "Failed to read from file '%s'", filename); PrintAndLogEx(FAILED, "File: " _YELLOW_("%s") ": not found or locked.", filename);
return 0; return PM3_EFILE;
} }
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
long fsize = ftell(f); long fsize = ftell(f);
@ -1709,24 +1709,24 @@ static int loadKeys(char *filename) {
free(dump); free(dump);
PrintAndLogEx(SUCCESS, "%u keys loaded", i); PrintAndLogEx(SUCCESS, "%u keys loaded", i);
return 1; return PM3_SUCCESS;
} }
static int saveKeys(char *filename) { static int saveKeys(char *filename) {
FILE *f; FILE *f;
f = fopen(filename, "wb"); f = fopen(filename, "wb");
if (!f) { if (!f) {
PrintAndLogEx(NORMAL, "[!] error opening file %s\n", filename); PrintAndLogEx(FAILED, "File: " _YELLOW_("%s") ": not found or locked.", filename);
return 0; return PM3_EFILE;
} }
for (uint8_t i = 0; i < ICLASS_KEYS_MAX; i++) { for (uint8_t i = 0; i < ICLASS_KEYS_MAX; i++) {
if (fwrite(iClass_Key_Table[i], 8, 1, f) != 1) { if (fwrite(iClass_Key_Table[i], 8, 1, f) != 1) {
PrintAndLogEx(WARNING, "save key failed to write to file: %s", filename); PrintAndLogEx(WARNING, "save key failed to write to file:" _YELLOW_("%s"), filename);
break; break;
} }
} }
fclose(f); fclose(f);
return 0; return PM3_SUCCESS;
} }
static int printKeys(void) { static int printKeys(void) {
@ -1734,7 +1734,7 @@ static int printKeys(void) {
for (uint8_t i = 0; i < ICLASS_KEYS_MAX; i++) for (uint8_t i = 0; i < ICLASS_KEYS_MAX; i++)
PrintAndLogEx(NORMAL, "%u: %s", i, sprint_hex(iClass_Key_Table[i], 8)); PrintAndLogEx(NORMAL, "%u: %s", i, sprint_hex(iClass_Key_Table[i], 8));
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
return 0; return PM3_SUCCESS;
} }
static int CmdHFiClassManageKeys(const char *Cmd) { static int CmdHFiClassManageKeys(const char *Cmd) {
@ -1824,7 +1824,7 @@ static int CmdHFiClassManageKeys(const char *Cmd) {
return saveKeys(filename); return saveKeys(filename);
break; break;
} }
return 0; return PM3_SUCCESS;
} }
static int CmdHFiClassCheckKeys(const char *Cmd) { static int CmdHFiClassCheckKeys(const char *Cmd) {
@ -2032,7 +2032,7 @@ out:
DropField(); DropField();
free(pre); free(pre);
free(keyBlock); free(keyBlock);
return 0; return PM3_SUCCESS;
} }
static int cmp_uint32(const void *a, const void *b) { static int cmp_uint32(const void *a, const void *b) {
@ -2184,7 +2184,7 @@ static int CmdHFiClassLookUp(const char *Cmd) {
free(prekey); free(prekey);
free(keyBlock); free(keyBlock);
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
return 0; return PM3_SUCCESS;
} }
int LoadDictionaryKeyFile(char *filename, uint8_t **keys, int *keycnt) { int LoadDictionaryKeyFile(char *filename, uint8_t **keys, int *keycnt) {
@ -2234,7 +2234,7 @@ int LoadDictionaryKeyFile(char *filename, uint8_t **keys, int *keycnt) {
} }
fclose(f); fclose(f);
PrintAndLogEx(SUCCESS, "Loaded " _GREEN_("%2d") " keys from %s", *keycnt, filename); PrintAndLogEx(SUCCESS, "Loaded " _GREEN_("%2d") " keys from %s", *keycnt, filename);
return 0; return PM3_SUCCESS;
} }
// precalc diversified keys and their MAC // precalc diversified keys and their MAC
@ -2253,7 +2253,7 @@ int GenerateMacFromKeyFile(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_e
doMAC(CCNR, div_key, list[i].mac); doMAC(CCNR, div_key, list[i].mac);
} }
return 0; return PM3_SUCCESS;
} }
int GenerateFromKeyFile(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, int keycnt, iclass_prekey_t *list) { int GenerateFromKeyFile(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elite, uint8_t *keys, int keycnt, iclass_prekey_t *list) {
@ -2273,7 +2273,7 @@ int GenerateFromKeyFile(uint8_t *CSN, uint8_t *CCNR, bool use_raw, bool use_elit
// generate MAC // generate MAC
doMAC(CCNR, div_key, list[i].mac); doMAC(CCNR, div_key, list[i].mac);
} }
return 0; return PM3_SUCCESS;
} }
// print diversified keys // print diversified keys
@ -2403,7 +2403,7 @@ static int CmdHFiClassPermuteKey(const char *Cmd) {
permutekey(key, key_iclass_format); permutekey(key, key_iclass_format);
PrintAndLogEx(SUCCESS, "holiman std key | %s \n", sprint_hex(key_iclass_format, 8)); PrintAndLogEx(SUCCESS, "holiman std key | %s \n", sprint_hex(key_iclass_format, 8));
} }
return 0; return PM3_SUCCESS;
} }
static command_t CommandTable[] = { static command_t CommandTable[] = {
@ -2433,7 +2433,7 @@ static command_t CommandTable[] = {
static int CmdHelp(const char *Cmd) { static int CmdHelp(const char *Cmd) {
(void)Cmd; // Cmd is not used so far (void)Cmd; // Cmd is not used so far
CmdsHelp(CommandTable); CmdsHelp(CommandTable);
return 0; return PM3_SUCCESS;
} }
int CmdHFiClass(const char *Cmd) { int CmdHFiClass(const char *Cmd) {
@ -2503,6 +2503,6 @@ int readIclass(bool loop, bool verbose) {
if (!loop) break; if (!loop) break;
} }
DropField(); DropField();
return 0; return PM3_SUCCESS;
} }

View file

@ -947,14 +947,14 @@ static int CmdLegicDump(const char *Cmd) {
PrintAndLogEx(WARNING, "Could not create file name %s", filename); PrintAndLogEx(WARNING, "Could not create file name %s", filename);
if (data) if (data)
free(data); free(data);
return 5; return PM3_EFILE;
} }
fwrite(data, 1, readlen, f); fwrite(data, 1, readlen, f);
fflush(f); fflush(f);
fclose(f); fclose(f);
free(data); free(data);
PrintAndLogEx(SUCCESS, "Wrote %d bytes to %s", readlen, filename); PrintAndLogEx(SUCCESS, "Wrote %d bytes to %s", readlen, filename);
return 0; return PM3_SUCCESS;
} }
static int CmdLegicRestore(const char *Cmd) { static int CmdLegicRestore(const char *Cmd) {
@ -1017,7 +1017,7 @@ static int CmdLegicRestore(const char *Cmd) {
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "File %s not found or locked", filename); PrintAndLogEx(WARNING, "File %s not found or locked", filename);
free(data); free(data);
return 3; return PM3_EFILE;
} }
// verify size of dumpfile is the same as card. // verify size of dumpfile is the same as card.
@ -1083,7 +1083,7 @@ static int CmdLegicRestore(const char *Cmd) {
free(data); free(data);
PrintAndLogEx(SUCCESS, "\nWrote %d bytes to card from file %s", numofbytes, filename); PrintAndLogEx(SUCCESS, "\nWrote %d bytes to card from file %s", numofbytes, filename);
return 0; return PM3_SUCCESS;
} }
static int CmdLegicELoad(const char *Cmd) { static int CmdLegicELoad(const char *Cmd) {
@ -1133,7 +1133,7 @@ static int CmdLegicELoad(const char *Cmd) {
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "File %s not found or locked", filename); PrintAndLogEx(WARNING, "File %s not found or locked", filename);
free(data); free(data);
return 1; return PM3_EFILE;
} }
// load file // load file
@ -1153,7 +1153,7 @@ static int CmdLegicELoad(const char *Cmd) {
free(data); free(data);
PrintAndLogEx(SUCCESS, "\nLoaded %d bytes from file: %s to emulator memory", numofbytes, filename); PrintAndLogEx(SUCCESS, "\nLoaded %d bytes from file: %s to emulator memory", numofbytes, filename);
return 0; return PM3_SUCCESS;
} }
static int CmdLegicESave(const char *Cmd) { static int CmdLegicESave(const char *Cmd) {

View file

@ -177,7 +177,7 @@ static int CmdLFHitagList(const char *Cmd) {
f = fopen(filename, "wb"); f = fopen(filename, "wb");
if (!f) { if (!f) {
PrintAndLogEx(WARNING, "Error: Could not open file [%s]", filename); PrintAndLogEx(WARNING, "Error: Could not open file [%s]", filename);
return 1; return PM3_EFILE;
} }
} }

View file

@ -559,7 +559,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
f = fopen(filename, "rb"); f = fopen(filename, "rb");
if (!f) { if (!f) {
PrintAndLogEx(FAILED, "Firmware file " _YELLOW_("%s") " not found or locked.", filename); PrintAndLogEx(FAILED, "Firmware file " _YELLOW_("%s") " not found or locked.", filename);
return 1; return PM3_EFILE;
} }
// get filesize in order to malloc memory // get filesize in order to malloc memory
@ -588,7 +588,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
if (!f) { if (!f) {
PrintAndLogEx(FAILED, "SHA-512 file not found or locked."); PrintAndLogEx(FAILED, "SHA-512 file not found or locked.");
free(dump); free(dump);
return 1; return PM3_EFILE;
} }
// get filesize in order to malloc memory // get filesize in order to malloc memory
@ -683,7 +683,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
} else { } else {
PrintAndLogEx(FAILED, "Sim module firmware upgrade " _RED_("failed")); PrintAndLogEx(FAILED, "Sim module firmware upgrade " _RED_("failed"));
} }
return 0; return PM3_SUCCESS;
} }
static int CmdSmartInfo(const char *Cmd) { static int CmdSmartInfo(const char *Cmd) {

View file

@ -102,14 +102,14 @@ int saveFile(const char *preferredName, const char *suffix, const void *data, si
if (!f) { if (!f) {
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName); PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName);
free(fileName); free(fileName);
return 1; return PM3_EFILE;
} }
fwrite(data, 1, datalen, f); fwrite(data, 1, datalen, f);
fflush(f); fflush(f);
fclose(f); fclose(f);
PrintAndLogDevice(SUCCESS, "saved %u bytes to binary file " _YELLOW_("%s"), datalen, fileName); PrintAndLogDevice(SUCCESS, "saved %u bytes to binary file " _YELLOW_("%s"), datalen, fileName);
free(fileName); free(fileName);
return 0; return PM3_SUCCESS;
} }
int saveFileEML(const char *preferredName, uint8_t *data, size_t datalen, size_t blocksize) { int saveFileEML(const char *preferredName, uint8_t *data, size_t datalen, size_t blocksize) {
@ -118,7 +118,7 @@ int saveFileEML(const char *preferredName, uint8_t *data, size_t datalen, size_t
char *fileName = newfilenamemcopy(preferredName, ".eml"); char *fileName = newfilenamemcopy(preferredName, ".eml");
if (fileName == NULL) return 1; if (fileName == NULL) return 1;
int retval = 0; int retval = PM3_SUCCESS;
int blocks = datalen / blocksize; int blocks = datalen / blocksize;
uint16_t currblock = 1; uint16_t currblock = 1;
@ -128,7 +128,7 @@ int saveFileEML(const char *preferredName, uint8_t *data, size_t datalen, size_t
FILE *f = fopen(fileName, "w+"); FILE *f = fopen(fileName, "w+");
if (!f) { if (!f) {
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName); PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName);
retval = 1; retval = PM3_EFILE;
goto out; goto out;
} }
@ -163,7 +163,7 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s
char *fileName = newfilenamemcopy(preferredName, ".json"); char *fileName = newfilenamemcopy(preferredName, ".json");
if (fileName == NULL) return 1; if (fileName == NULL) return 1;
int retval = 0; int retval = PM3_SUCCESS;
json_t *root = json_object(); json_t *root = json_object();
JsonSaveStr(root, "Created", "proxmark3"); JsonSaveStr(root, "Created", "proxmark3");
@ -292,13 +292,13 @@ int loadFile(const char *preferredName, const char *suffix, void *data, size_t m
char *fileName = filenamemcopy(preferredName, suffix); char *fileName = filenamemcopy(preferredName, suffix);
if (fileName == NULL) return 1; if (fileName == NULL) return 1;
int retval = 0; int retval = PM3_SUCCESS;
FILE *f = fopen(fileName, "rb"); FILE *f = fopen(fileName, "rb");
if (!f) { if (!f) {
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName); PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName);
free(fileName); free(fileName);
return 1; return PM3_EFILE;
} }
// get filesize in order to malloc memory // get filesize in order to malloc memory
@ -354,12 +354,12 @@ int loadFileEML(const char *preferredName, void *data, size_t *datalen) {
if (fileName == NULL) return 1; if (fileName == NULL) return 1;
size_t counter = 0; size_t counter = 0;
int retval = 0, hexlen = 0; int retval = PM3_SUCCESS, hexlen = 0;
FILE *f = fopen(fileName, "r"); FILE *f = fopen(fileName, "r");
if (!f) { if (!f) {
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName); PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName);
retval = 1; retval = PM3_EFILE;
goto out; goto out;
} }
@ -411,7 +411,7 @@ int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_
json_t *root; json_t *root;
json_error_t error; json_error_t error;
int retval = 0; int retval = PM3_SUCCESS;
root = json_load_file(fileName, 0, &error); root = json_load_file(fileName, 0, &error);
if (!root) { if (!root) {
@ -528,12 +528,12 @@ int loadFileDICTIONARY(const char *preferredName, void *data, size_t *datalen, u
char line[255]; char line[255];
size_t counter = 0; size_t counter = 0;
int retval = 0; int retval = PM3_SUCCESS;
FILE *f = fopen(fileName, "r"); FILE *f = fopen(fileName, "r");
if (!f) { if (!f) {
PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName); PrintAndLogDevice(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", fileName);
retval = 1; retval = PM3_EFILE;
goto out; goto out;
} }
@ -602,7 +602,7 @@ int convertOldMfuDump(uint8_t **dump, size_t *dumplen) {
free(*dump); free(*dump);
*dump = (uint8_t *) mfu_dump; *dump = (uint8_t *) mfu_dump;
PrintAndLogDevice(SUCCESS, "old mfu dump format, was converted on load to " _GREEN_("%d") " pages", mfu_dump->pages + 1); PrintAndLogDevice(SUCCESS, "old mfu dump format, was converted on load to " _GREEN_("%d") " pages", mfu_dump->pages + 1);
return 0; return PM3_SUCCESS;
} }