mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
good const, bad const, fixing -Wincompatible-pointer-types-discards-qualifiers
This commit is contained in:
@@ -236,7 +236,7 @@ int opterr = 1; /* if error message should be printed */
|
||||
int optind = 1; /* index into parent argv vector */
|
||||
int optopt = '?'; /* character checked for validity */
|
||||
int optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
const char *optarg; /* argument associated with option */
|
||||
#endif
|
||||
|
||||
#define PRINT_ERROR ((opterr) && (*options != ':'))
|
||||
@@ -259,7 +259,7 @@ static int parse_long_options(char *const *, const char *,
|
||||
static int gcd(int, int);
|
||||
static void permute_args(int, int, int, char *const *);
|
||||
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
static const char *place = EMSG; /* option letter processing */
|
||||
|
||||
/* XXX: set optreset to 1 rather than these two */
|
||||
static int nonopt_start = -1; /* first non option argument (for permute) */
|
||||
@@ -377,7 +377,7 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end,
|
||||
static int
|
||||
parse_long_options(char *const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx, int short_too) {
|
||||
char *current_argv, *has_equal;
|
||||
const char *current_argv, *has_equal;
|
||||
size_t current_argv_len;
|
||||
int i, match;
|
||||
|
||||
@@ -4325,9 +4325,9 @@ void arg_print_option(FILE *fp,
|
||||
static
|
||||
void arg_print_gnuswitch(FILE *fp, struct arg_hdr * *table) {
|
||||
int tabindex;
|
||||
char *format1 = " -%c";
|
||||
char *format2 = " [-%c";
|
||||
char *suffix = "";
|
||||
const char *format1 = " -%c";
|
||||
const char *format2 = " [-%c";
|
||||
const char *suffix = "";
|
||||
|
||||
/* print all mandatory switches that are without argument values */
|
||||
for (tabindex = 0;
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
|
||||
void **argtable = NULL;
|
||||
size_t argtableLen = 0;
|
||||
char *programName = NULL;
|
||||
char *programHint = NULL;
|
||||
char *programHelp = NULL;
|
||||
const char *programName = NULL;
|
||||
const char *programHint = NULL;
|
||||
const char *programHelp = NULL;
|
||||
char buf[500] = {0};
|
||||
|
||||
int CLIParserInit(char *vprogramName, char *vprogramHint, char *vprogramHelp) {
|
||||
int CLIParserInit(const char *vprogramName, const char *vprogramHint, const char *vprogramHelp) {
|
||||
argtable = NULL;
|
||||
argtableLen = 0;
|
||||
programName = vprogramName;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#define CLIGetHexWithReturn(paramnum, data, datalen) if (CLIParamHexToBuf(arg_get_str(paramnum), data, sizeof(data), datalen)) {CLIParserFree();return 1;}
|
||||
#define CLIGetStrWithReturn(paramnum, data, datalen) if (CLIParamStrToBuf(arg_get_str(paramnum), data, sizeof(data), datalen)) {CLIParserFree();return 1;}
|
||||
|
||||
int CLIParserInit(char *vprogramName, char *vprogramHint, char *vprogramHelp);
|
||||
int CLIParserInit(const char *vprogramName, const char *vprogramHint, const char *vprogramHelp);
|
||||
int CLIParserParseString(const char *str, void *vargtable[], size_t vargtableLen, bool allowEmptyExec);
|
||||
int CLIParserParseStringEx(const char *str, void *vargtable[], size_t vargtableLen, bool allowEmptyExec, bool clueData);
|
||||
int CLIParserParseArg(int argc, char **argv, void *vargtable[], size_t vargtableLen, bool allowEmptyExec);
|
||||
|
||||
@@ -68,7 +68,7 @@ int getopt_long_only(int, char *const *, const char *,
|
||||
#define _GETOPT_DECLARED
|
||||
int getopt(int, char *const [], const char *);
|
||||
|
||||
extern char *optarg; /* getopt(3) external variables */
|
||||
extern const char *optarg; /* getopt(3) external variables */
|
||||
extern int optind, opterr, optopt;
|
||||
#endif
|
||||
#ifndef _OPTRESET_DECLARED
|
||||
|
||||
+2
-2
@@ -136,7 +136,7 @@ static const manufactureName manufactureMapping[] = {
|
||||
// get a product description based on the UID
|
||||
// uid[8] tag uid
|
||||
// returns description of the best match
|
||||
char *getTagInfo(uint8_t uid) {
|
||||
const char *getTagInfo(uint8_t uid) {
|
||||
|
||||
int i;
|
||||
int len = sizeof(manufactureMapping) / sizeof(manufactureName);
|
||||
@@ -566,7 +566,7 @@ int CmdHF14AInfo(const char *Cmd) {
|
||||
pos++;
|
||||
}
|
||||
if (card.ats[0] > pos && card.ats[0] < card.ats_len - 2) {
|
||||
char *tip = "";
|
||||
const char *tip = "";
|
||||
if (card.ats[0] - pos >= 7) {
|
||||
if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x01\xBC\xD6", 7) == 0) {
|
||||
tip = "-> MIFARE Plus X 2K or 4K";
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@
|
||||
// structure and database for uid -> tagtype lookups
|
||||
typedef struct {
|
||||
uint8_t uid;
|
||||
char *desc;
|
||||
const char *desc;
|
||||
} manufactureName;
|
||||
|
||||
int CmdHF14A(const char *Cmd);
|
||||
@@ -48,7 +48,7 @@ int CmdHF14ACmdRaw(const char *Cmd);
|
||||
int CmdHF14ACUIDs(const char *Cmd);
|
||||
int CmdHF14AAntiFuzz(const char *Cmd);
|
||||
|
||||
char *getTagInfo(uint8_t uid);
|
||||
const char *getTagInfo(uint8_t uid);
|
||||
int Hf14443_4aGetCardData(iso14a_card_select_t *card);
|
||||
int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen);
|
||||
int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen);
|
||||
|
||||
+5
-5
@@ -46,7 +46,7 @@
|
||||
typedef struct {
|
||||
uint64_t uid;
|
||||
int mask; // how many MSB bits used
|
||||
char *desc;
|
||||
const char *desc;
|
||||
} productName;
|
||||
|
||||
const productName uidmapping[] = {
|
||||
@@ -235,7 +235,7 @@ int getUID(uint8_t *buf) {
|
||||
// get a product description based on the UID
|
||||
// uid[8] tag uid
|
||||
// returns description of the best match
|
||||
static char *getTagInfo_15(uint8_t *uid) {
|
||||
static const char *getTagInfo_15(uint8_t *uid) {
|
||||
uint64_t myuid, mask;
|
||||
int i = 0, best = -1;
|
||||
memcpy(&myuid, uid, sizeof(uint64_t));
|
||||
@@ -259,7 +259,7 @@ static char *getTagInfo_15(uint8_t *uid) {
|
||||
}
|
||||
|
||||
// return a clear-text message to an errorcode
|
||||
static char *TagErrorStr(uint8_t error) {
|
||||
static const char *TagErrorStr(uint8_t error) {
|
||||
switch (error) {
|
||||
case 0x01:
|
||||
return "The command is not supported";
|
||||
@@ -350,7 +350,7 @@ int usage_15_dump(void) {
|
||||
return 0;
|
||||
}
|
||||
int usage_15_restore(void) {
|
||||
char *options[][2] = {
|
||||
const char *options[][2] = {
|
||||
{"h", "this help"},
|
||||
{"-2", "use slower '1 out of 256' mode"},
|
||||
{"-o", "set OPTION Flag (needed for TI)"},
|
||||
@@ -364,7 +364,7 @@ int usage_15_restore(void) {
|
||||
return 0;
|
||||
}
|
||||
int usage_15_raw(void) {
|
||||
char *options[][2] = {
|
||||
const char *options[][2] = {
|
||||
{"-r", "do not read response" },
|
||||
{"-2", "use slower '1 out of 256' mode" },
|
||||
{"-c", "calculate and append CRC" },
|
||||
|
||||
+1
-1
@@ -621,7 +621,7 @@ void CheckSlash(char *fileName) {
|
||||
strcat(fileName, "/");
|
||||
}
|
||||
|
||||
int GetExistsFileNameJson(char *prefixDir, char *reqestedFileName, char *fileName) {
|
||||
int GetExistsFileNameJson(const char *prefixDir, const char *reqestedFileName, char *fileName) {
|
||||
fileName[0] = 0x00;
|
||||
strcpy(fileName, get_my_executable_directory());
|
||||
CheckSlash(fileName);
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ char *GetVersionStr(uint8_t major, uint8_t minor) {
|
||||
void GetKeySettings(uint8_t *aid) {
|
||||
|
||||
char messStr[512] = {0x00};
|
||||
char *str = messStr;
|
||||
const char *str = messStr;
|
||||
uint8_t isOK = 0;
|
||||
uint32_t options;
|
||||
UsbCommand c = {CMD_MIFARE_DESFIRE};
|
||||
|
||||
@@ -109,7 +109,7 @@ static void print_progress_header(void) {
|
||||
}
|
||||
|
||||
|
||||
void hardnested_print_progress(uint32_t nonces, char *activity, float brute_force, uint64_t min_diff_print_time) {
|
||||
void hardnested_print_progress(uint32_t nonces, const char *activity, float brute_force, uint64_t min_diff_print_time) {
|
||||
static uint64_t last_print_time = 0;
|
||||
if (msclock() - last_print_time > min_diff_print_time) {
|
||||
last_print_time = msclock();
|
||||
|
||||
@@ -42,7 +42,7 @@ typedef struct noncelist {
|
||||
} noncelist_t;
|
||||
|
||||
int mfnestedhard(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t *trgkey, bool nonce_file_read, bool nonce_file_write, bool slow, int tests, uint64_t *foundkey, char *filename);
|
||||
void hardnested_print_progress(uint32_t nonces, char *activity, float brute_force, uint64_t min_diff_print_time);
|
||||
void hardnested_print_progress(uint32_t nonces, const char *activity, float brute_force, uint64_t min_diff_print_time);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -251,7 +251,7 @@ int CmdTIDemod(const char *Cmd) {
|
||||
|
||||
//crc = crc16_ccitt(message, sizeof(message);
|
||||
|
||||
char *crcStr = (crc == (shift2 & 0xFFFF)) ? _GREEN_("Passed") : _RED_("Failed");
|
||||
const char *crcStr = (crc == (shift2 & 0xFFFF)) ? _GREEN_("Passed") : _RED_("Failed");
|
||||
|
||||
PrintAndLogEx(INFO, "Tag data = %08X%08X [Crc %04X %s]", shift1, shift0, crc, crcStr);
|
||||
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ void dumpCommandsRecursive(const command_t cmds[], int markdown) {
|
||||
}
|
||||
|
||||
while (cmds[i].Name) {
|
||||
char *cmd_offline = "N";
|
||||
const char *cmd_offline = "N";
|
||||
if (cmds[i].Help[0] == '{' && ++i) continue;
|
||||
|
||||
if (cmds[i].Offline)
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ int str_ends_with(const char *str, const char *suffix) {
|
||||
/**
|
||||
* Utility to check the ending of a string (used to check file suffix)
|
||||
*/
|
||||
bool endsWith(char *base, char *str) {
|
||||
bool endsWith(const char *base, const char *str) {
|
||||
int blen = strlen(base);
|
||||
int slen = strlen(str);
|
||||
return (blen >= slen) && (0 == strcmp(base + blen - slen, str));
|
||||
@@ -125,7 +125,7 @@ int CmdScriptRun(const char *Cmd) {
|
||||
int arg_len = 0;
|
||||
sscanf(Cmd, "%127s%n %255[^\n\r]%n", script_name, &name_len, arguments, &arg_len);
|
||||
|
||||
char *suffix = "";
|
||||
const char *suffix = "";
|
||||
if (!endsWith(script_name, ".lua")) {
|
||||
suffix = ".lua";
|
||||
}
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, ui
|
||||
}
|
||||
|
||||
// Draw the CRC column
|
||||
char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
|
||||
const char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
|
||||
|
||||
EndOfTransmissionTimestamp = timestamp + duration;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ enum asn1_tag_t {
|
||||
|
||||
struct asn1_tag {
|
||||
tlv_tag_t tag;
|
||||
char *name;
|
||||
const char *name;
|
||||
enum asn1_tag_t type;
|
||||
const void *data;
|
||||
};
|
||||
|
||||
@@ -71,7 +71,7 @@ static bool print_cb(void *data, const struct tlv *tlv, int level, bool is_leaf)
|
||||
return true;
|
||||
}
|
||||
|
||||
int asn1_print(uint8_t *asn1buf, size_t asn1buflen, char *indent) {
|
||||
int asn1_print(uint8_t *asn1buf, size_t asn1buflen, const char *indent) {
|
||||
|
||||
struct tlvdb *t = tlvdb_parse_multi(asn1buf, asn1buflen);
|
||||
if (t) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int asn1_print(uint8_t *asn1buf, size_t asn1buflen, char *indent);
|
||||
int asn1_print(uint8_t *asn1buf, size_t asn1buflen, const char *indent);
|
||||
int ecdsa_asn1_get_signature(uint8_t *signature, size_t signaturelen, uint8_t *rval, uint8_t *sval);
|
||||
|
||||
#endif /* asn1utils.h */
|
||||
|
||||
@@ -121,7 +121,7 @@ int sha512hash(uint8_t *input, int length, uint8_t *hash) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ecdsa_init_str(mbedtls_ecdsa_context *ctx, char *key_d, char *key_x, char *key_y) {
|
||||
int ecdsa_init_str(mbedtls_ecdsa_context *ctx, const char *key_d, const char *key_x, const char *key_y) {
|
||||
if (!ctx)
|
||||
return 1;
|
||||
|
||||
@@ -279,7 +279,7 @@ exit:
|
||||
return res;
|
||||
}
|
||||
|
||||
int ecdsa_signature_create_test(char *key_d, char *key_x, char *key_y, char *random, uint8_t *input, int length, uint8_t *signature, size_t *signaturelen) {
|
||||
int ecdsa_signature_create_test(const char *key_d, const char *key_x, const char *key_y, const char *random, uint8_t *input, int length, uint8_t *signature, size_t *signaturelen) {
|
||||
int res;
|
||||
*signaturelen = 0;
|
||||
|
||||
@@ -299,7 +299,7 @@ int ecdsa_signature_create_test(char *key_d, char *key_x, char *key_y, char *ran
|
||||
return res;
|
||||
}
|
||||
|
||||
int ecdsa_signature_verify_keystr(char *key_x, char *key_y, uint8_t *input, int length, uint8_t *signature, size_t signaturelen) {
|
||||
int ecdsa_signature_verify_keystr(const char *key_x, const char *key_y, uint8_t *input, int length, uint8_t *signature, size_t signaturelen) {
|
||||
int res;
|
||||
uint8_t shahash[32] = {0};
|
||||
res = sha256hash(input, length, shahash);
|
||||
|
||||
@@ -277,7 +277,7 @@ int CodeCmp(const char *code1, const char *code2) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const APDUCode *const GetAPDUCode(uint8_t sw1, uint8_t sw2) {
|
||||
const APDUCode * GetAPDUCode(uint8_t sw1, uint8_t sw2) {
|
||||
char buf[6] = {0};
|
||||
int res;
|
||||
int mineq = APDUCodeTableLen;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user