good const, bad const, fixing -Wincompatible-pointer-types-discards-qualifiers
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef struct {
|
||||
const char *Description;
|
||||
} APDUCode;
|
||||
|
||||
const APDUCode *const GetAPDUCode(uint8_t sw1, uint8_t sw2);
|
||||
const APDUCode *GetAPDUCode(uint8_t sw1, uint8_t sw2);
|
||||
const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -652,7 +652,7 @@ void InitTransactionParameters(struct tlvdb *tlvRoot, bool paramLoadJSON, enum T
|
||||
}
|
||||
|
||||
//9F66:(Terminal Transaction Qualifiers (TTQ)) len:4
|
||||
char *qVSDC = "\x26\x00\x00\x00";
|
||||
const char *qVSDC = "\x26\x00\x00\x00";
|
||||
if (GenACGPO) {
|
||||
qVSDC = "\x26\x80\x00\x00";
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ enum emv_tag_t {
|
||||
|
||||
struct emv_tag {
|
||||
tlv_tag_t tag;
|
||||
char *name;
|
||||
const char *name;
|
||||
enum emv_tag_t type;
|
||||
const void *data;
|
||||
};
|
||||
@@ -819,8 +819,8 @@ bool emv_tag_dump(const struct tlv *tlv, FILE *f, int level) {
|
||||
return true;
|
||||
}
|
||||
|
||||
char *emv_get_tag_name(const struct tlv *tlv) {
|
||||
static char *defstr = "";
|
||||
const char *emv_get_tag_name(const struct tlv *tlv) {
|
||||
static const char *defstr = "";
|
||||
|
||||
if (!tlv)
|
||||
return defstr;
|
||||
|
||||
@@ -35,6 +35,6 @@
|
||||
# define EMVCID_REASON_MASK 0x07
|
||||
|
||||
bool emv_tag_dump(const struct tlv *tlv, FILE *f, int level);
|
||||
char *emv_get_tag_name(const struct tlv *tlv);
|
||||
const char *emv_get_tag_name(const struct tlv *tlv);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,7 @@ static const char *PSElist [] = {
|
||||
};
|
||||
//static const size_t PSElistLen = sizeof(PSElist)/sizeof(char*);
|
||||
|
||||
char *TransactionTypeStr[] = {
|
||||
const char *TransactionTypeStr[] = {
|
||||
"MSD",
|
||||
"VSDC",
|
||||
"qVCDCMCHIP",
|
||||
@@ -434,7 +434,7 @@ int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldO
|
||||
int res;
|
||||
bool fileFound = false;
|
||||
|
||||
char *PSE_or_PPSE = PSENum == 1 ? "PSE" : "PPSE";
|
||||
const char *PSE_or_PPSE = PSENum == 1 ? "PSE" : "PPSE";
|
||||
|
||||
// select PPSE
|
||||
res = EMVSelectPSE(channel, ActivateField, true, PSENum, data, sizeof(data), &datalen, &sw);
|
||||
|
||||
@@ -43,7 +43,7 @@ enum TransactionType {
|
||||
TT_QVSDCMCHIP,
|
||||
TT_CDA,
|
||||
};
|
||||
extern char *TransactionTypeStr[];
|
||||
extern const char *TransactionTypeStr[];
|
||||
|
||||
typedef struct {
|
||||
uint8_t CLA;
|
||||
|
||||
@@ -60,7 +60,7 @@ static const ApplicationDataElm ApplicationData[] = {
|
||||
};
|
||||
int ApplicationDataLen = sizeof(ApplicationData) / sizeof(ApplicationDataElm);
|
||||
|
||||
char *GetApplicationDataName(tlv_tag_t tag) {
|
||||
const char *GetApplicationDataName(tlv_tag_t tag) {
|
||||
for (int i = 0; i < ApplicationDataLen; i++)
|
||||
if (ApplicationData[i].Tag == tag)
|
||||
return ApplicationData[i].Name;
|
||||
@@ -68,7 +68,7 @@ char *GetApplicationDataName(tlv_tag_t tag) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int JsonSaveJsonObject(json_t *root, char *path, json_t *value) {
|
||||
int JsonSaveJsonObject(json_t *root, const char *path, json_t *value) {
|
||||
json_error_t error;
|
||||
|
||||
if (strlen(path) < 1)
|
||||
@@ -86,15 +86,15 @@ int JsonSaveJsonObject(json_t *root, char *path, json_t *value) {
|
||||
}
|
||||
}
|
||||
|
||||
int JsonSaveInt(json_t *root, char *path, int value) {
|
||||
int JsonSaveInt(json_t *root, const char *path, int value) {
|
||||
return JsonSaveJsonObject(root, path, json_integer(value));
|
||||
}
|
||||
|
||||
int JsonSaveStr(json_t *root, char *path, char *value) {
|
||||
int JsonSaveStr(json_t *root, const char *path, const char *value) {
|
||||
return JsonSaveJsonObject(root, path, json_string(value));
|
||||
};
|
||||
|
||||
int JsonSaveBufAsHexCompact(json_t *elm, char *path, uint8_t *data, size_t datalen) {
|
||||
int JsonSaveBufAsHexCompact(json_t *elm, const char *path, uint8_t *data, size_t datalen) {
|
||||
char *msg = sprint_hex_inrow(data, datalen);
|
||||
if (msg && strlen(msg) && msg[strlen(msg) - 1] == ' ')
|
||||
msg[strlen(msg) - 1] = '\0';
|
||||
@@ -102,7 +102,7 @@ int JsonSaveBufAsHexCompact(json_t *elm, char *path, uint8_t *data, size_t datal
|
||||
return JsonSaveStr(elm, path, msg);
|
||||
}
|
||||
|
||||
int JsonSaveBufAsHex(json_t *elm, char *path, uint8_t *data, size_t datalen) {
|
||||
int JsonSaveBufAsHex(json_t *elm, const char *path, uint8_t *data, size_t datalen) {
|
||||
char *msg = sprint_hex(data, datalen);
|
||||
if (msg && strlen(msg) && msg[strlen(msg) - 1] == ' ')
|
||||
msg[strlen(msg) - 1] = '\0';
|
||||
@@ -110,7 +110,7 @@ int JsonSaveBufAsHex(json_t *elm, char *path, uint8_t *data, size_t datalen) {
|
||||
return JsonSaveStr(elm, path, msg);
|
||||
}
|
||||
|
||||
int JsonSaveHex(json_t *elm, char *path, uint64_t data, int datalen) {
|
||||
int JsonSaveHex(json_t *elm, const char *path, uint64_t data, int datalen) {
|
||||
uint8_t bdata[8] = {0};
|
||||
int len = 0;
|
||||
if (!datalen) {
|
||||
@@ -130,7 +130,7 @@ int JsonSaveHex(json_t *elm, char *path, uint64_t data, int datalen) {
|
||||
return JsonSaveBufAsHex(elm, path, bdata, len);
|
||||
}
|
||||
|
||||
int JsonSaveTLVValue(json_t *root, char *path, struct tlvdb *tlvdbelm) {
|
||||
int JsonSaveTLVValue(json_t *root, const char *path, struct tlvdb *tlvdbelm) {
|
||||
const struct tlv *tlvelm = tlvdb_get_tlv(tlvdbelm);
|
||||
if (tlvelm)
|
||||
return JsonSaveBufAsHex(root, path, (uint8_t *)tlvelm->value, tlvelm->len);
|
||||
@@ -138,7 +138,7 @@ int JsonSaveTLVValue(json_t *root, char *path, struct tlvdb *tlvdbelm) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int JsonSaveTLVElm(json_t *elm, char *path, struct tlv *tlvelm, bool saveName, bool saveValue, bool saveAppDataLink) {
|
||||
int JsonSaveTLVElm(json_t *elm, const char *path, struct tlv *tlvelm, bool saveName, bool saveValue, bool saveAppDataLink) {
|
||||
json_error_t error;
|
||||
|
||||
if (strlen(path) < 1 || !tlvelm)
|
||||
@@ -164,11 +164,11 @@ int JsonSaveTLVElm(json_t *elm, char *path, struct tlv *tlvelm, bool saveName, b
|
||||
}
|
||||
|
||||
if (saveAppDataLink) {
|
||||
char *AppDataName = GetApplicationDataName(tlvelm->tag);
|
||||
const char *AppDataName = GetApplicationDataName(tlvelm->tag);
|
||||
if (AppDataName)
|
||||
JsonSaveStr(obj, "appdata", AppDataName);
|
||||
} else {
|
||||
char *name = emv_get_tag_name(tlvelm);
|
||||
const char *name = emv_get_tag_name(tlvelm);
|
||||
if (saveName && name && strlen(name) > 0 && strncmp(name, "Unknown", 7))
|
||||
JsonSaveStr(obj, "name", emv_get_tag_name(tlvelm));
|
||||
JsonSaveHex(obj, "tag", tlvelm->tag, 0);
|
||||
@@ -182,15 +182,15 @@ int JsonSaveTLVElm(json_t *elm, char *path, struct tlv *tlvelm, bool saveName, b
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JsonSaveTLVTreeElm(json_t *elm, char *path, struct tlvdb *tlvdbelm, bool saveName, bool saveValue, bool saveAppDataLink) {
|
||||
int JsonSaveTLVTreeElm(json_t *elm, const char *path, struct tlvdb *tlvdbelm, bool saveName, bool saveValue, bool saveAppDataLink) {
|
||||
return JsonSaveTLVElm(elm, path, (struct tlv *)tlvdb_get_tlv(tlvdbelm), saveName, saveValue, saveAppDataLink);
|
||||
}
|
||||
|
||||
int JsonSaveTLVTree(json_t *root, json_t *elm, char *path, struct tlvdb *tlvdbelm) {
|
||||
int JsonSaveTLVTree(json_t *root, json_t *elm, const char *path, struct tlvdb *tlvdbelm) {
|
||||
struct tlvdb *tlvp = tlvdbelm;
|
||||
while (tlvp) {
|
||||
const struct tlv *tlvpelm = tlvdb_get_tlv(tlvp);
|
||||
char *AppDataName = NULL;
|
||||
const char *AppDataName = NULL;
|
||||
if (tlvpelm)
|
||||
AppDataName = GetApplicationDataName(tlvpelm->tag);
|
||||
|
||||
@@ -265,7 +265,7 @@ bool HexToBuffer(const char *errormsg, const char *hexvalue, uint8_t *buffer, si
|
||||
return true;
|
||||
}
|
||||
|
||||
int JsonLoadStr(json_t *root, char *path, char *value) {
|
||||
int JsonLoadStr(json_t *root, const char *path, char *value) {
|
||||
if (!value)
|
||||
return 1;
|
||||
|
||||
@@ -282,7 +282,7 @@ int JsonLoadStr(json_t *root, char *path, char *value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JsonLoadBufAsHex(json_t *elm, char *path, uint8_t *data, size_t maxbufferlen, size_t *datalen) {
|
||||
int JsonLoadBufAsHex(json_t *elm, const char *path, uint8_t *data, size_t maxbufferlen, size_t *datalen) {
|
||||
if (datalen)
|
||||
*datalen = 0;
|
||||
|
||||
|
||||
@@ -15,26 +15,26 @@
|
||||
|
||||
typedef struct {
|
||||
tlv_tag_t Tag;
|
||||
char *Name;
|
||||
const char *Name;
|
||||
} ApplicationDataElm;
|
||||
|
||||
char *GetApplicationDataName(tlv_tag_t tag);
|
||||
const char *GetApplicationDataName(tlv_tag_t tag);
|
||||
|
||||
int JsonSaveJsonObject(json_t *root, char *path, json_t *value);
|
||||
int JsonSaveStr(json_t *root, char *path, char *value);
|
||||
int JsonSaveInt(json_t *root, char *path, int value);
|
||||
int JsonSaveBufAsHexCompact(json_t *elm, char *path, uint8_t *data, size_t datalen);
|
||||
int JsonSaveBufAsHex(json_t *elm, char *path, uint8_t *data, size_t datalen);
|
||||
int JsonSaveHex(json_t *elm, char *path, uint64_t data, int datalen);
|
||||
int JsonSaveJsonObject(json_t *root, const char *path, json_t *value);
|
||||
int JsonSaveStr(json_t *root, const char *path, const char *value);
|
||||
int JsonSaveInt(json_t *root, const char *path, int value);
|
||||
int JsonSaveBufAsHexCompact(json_t *elm, const char *path, uint8_t *data, size_t datalen);
|
||||
int JsonSaveBufAsHex(json_t *elm, const char *path, uint8_t *data, size_t datalen);
|
||||
int JsonSaveHex(json_t *elm, const char *path, uint64_t data, int datalen);
|
||||
|
||||
int JsonSaveTLVValue(json_t *root, char *path, struct tlvdb *tlvdbelm);
|
||||
int JsonSaveTLVElm(json_t *elm, char *path, struct tlv *tlvelm, bool saveName, bool saveValue, bool saveAppDataLink);
|
||||
int JsonSaveTLVTreeElm(json_t *elm, char *path, struct tlvdb *tlvdbelm, bool saveName, bool saveValue, bool saveAppDataLink);
|
||||
int JsonSaveTLVValue(json_t *root, const char *path, struct tlvdb *tlvdbelm);
|
||||
int JsonSaveTLVElm(json_t *elm, const char *path, struct tlv *tlvelm, bool saveName, bool saveValue, bool saveAppDataLink);
|
||||
int JsonSaveTLVTreeElm(json_t *elm, const char *path, struct tlvdb *tlvdbelm, bool saveName, bool saveValue, bool saveAppDataLink);
|
||||
|
||||
int JsonSaveTLVTree(json_t *root, json_t *elm, char *path, struct tlvdb *tlvdbelm);
|
||||
int JsonSaveTLVTree(json_t *root, json_t *elm, const char *path, struct tlvdb *tlvdbelm);
|
||||
|
||||
int JsonLoadStr(json_t *root, char *path, char *value);
|
||||
int JsonLoadBufAsHex(json_t *elm, char *path, uint8_t *data, size_t maxbufferlen, size_t *datalen);
|
||||
int JsonLoadStr(json_t *root, const char *path, char *value);
|
||||
int JsonLoadBufAsHex(json_t *elm, const char *path, uint8_t *data, size_t maxbufferlen, size_t *datalen);
|
||||
|
||||
bool ParamLoadFromJson(struct tlvdb *tlv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user