aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>2021-07-11 18:18:50 +0200
committerKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>2021-07-19 12:44:07 +0200
commit68bbfad3ae66cf681502700d7bb84f8db5ac7264 (patch)
treeaf41b97b5ca23b38187d9beda777db3a5dc90b27
parentffab364791cc08fe283396046b2d38d6e3ce7e65 (diff)
downloadneard-68bbfad3ae66cf681502700d7bb84f8db5ac7264.tar.gz
se: use proper format for integers (-Wformat)
Properly print signed and unsigned integers. This fixes warnings like: In file included from se/plugins/nfc.c:37: se/plugins/nfc.c: In function ‘nfc_netlink_event_se’: ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ se/plugins/nfc.c:200:2: note: in expansion of macro ‘DBG’ 200 | DBG("NFC %d SE %d", nfc_idx, se_idx); | ^~~ se/plugins/nfc.c:270:2: note: in expansion of macro ‘DBG’ 270 | DBG("NFC %d SE %d APDU len %zd", nfc_idx, se_idx, apdu_len); | ^~~ ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 6 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ In file included from se/../src/near.h:36, from se/seel.h:29, from se/se.c:34: se/se.c: In function ‘io_cb’: ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ se/se.c:119:2: note: in expansion of macro ‘DBG’ 119 | DBG("%zd %d", apdu_length, err); | ^~~ se/se.c: In function ‘se_path’: se/se.c:250:43: error: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 250 | return g_strdup_printf("%s/se/%s%d_%s_se%d", SEEL_PATH, | ~^ | | | int | %d 251 | ctrl, ctrl_idx, type, se_idx); | ~~~~~~ | | | uint32_t {aka unsigned int} Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
-rw-r--r--se/ace.c34
-rw-r--r--se/apdu.c8
-rw-r--r--se/plugins/nfc.c8
-rw-r--r--se/plugins/tizen.c2
-rw-r--r--se/se.c6
5 files changed, 29 insertions, 29 deletions
diff --git a/se/ace.c b/se/ace.c
index ef0e7e1..f8d492f 100644
--- a/se/ace.c
+++ b/se/ace.c
@@ -126,7 +126,7 @@ static void dump_rule(gpointer data, gpointer user_data)
for (i = 0; i < rule->aid_len; i++)
sprintf(aid + (3 * i), "%02X ", rule->aid[i]);
aid[3 * i] = 0;
- DBG(" AID [%zd]: %s", rule->aid_len, aid);
+ DBG(" AID [%zu]: %s", rule->aid_len, aid);
}
if (rule->hash_len == 0) {
@@ -135,7 +135,7 @@ static void dump_rule(gpointer data, gpointer user_data)
for (i = 0; i < rule->hash_len; i++)
sprintf(hash + (3 * i), "%02X ", rule->hash[i]);
hash[3 * i] = 0;
- DBG(" Hash [%zd]: %s", rule->hash_len, hash);
+ DBG(" Hash [%zu]: %s", rule->hash_len, hash);
}
if (rule->apdu_rules_len == 1) {
@@ -159,7 +159,7 @@ static void dump_rule(gpointer data, gpointer user_data)
n_rules = rule->apdu_rules_len /
sizeof(struct seel_ace_apdu_rule);
- DBG(" APDU rules (%zd)", n_rules);
+ DBG(" APDU rules (%zu)", n_rules);
for (i = 0; i < n_rules; i++) {
header = (uint8_t *)&apdu_rule->header;
mask = (uint8_t *)&apdu_rule->mask;
@@ -197,7 +197,7 @@ static int build_ref(struct seel_ace_rule *ace_rule,
switch (rule_ptr[0]) {
case AID_REF_DO:
do_length = rule_ptr[1];
- DBG("AID_REF_DO %zd", do_length);
+ DBG("AID_REF_DO %zu", do_length);
rule_ptr += 2;
if (remaining < do_length)
@@ -216,7 +216,7 @@ static int build_ref(struct seel_ace_rule *ace_rule,
case HASH_REF_DO:
do_length = rule_ptr[1];
- DBG("HASH_REF_DO %zd", do_length);
+ DBG("HASH_REF_DO %zu", do_length);
rule_ptr += 2;
if (remaining < do_length)
@@ -254,7 +254,7 @@ static int build_ar(struct seel_ace_rule *ace_rule,
switch (rule_ptr[0]) {
case APDU_AR_DO:
do_length = rule_ptr[1];
- DBG("APDU_AR_DO %zd", do_length);
+ DBG("APDU_AR_DO %zu", do_length);
rule_ptr += 2;
if (remaining < do_length)
@@ -274,7 +274,7 @@ static int build_ar(struct seel_ace_rule *ace_rule,
case NFC_AR_DO:
do_length = rule_ptr[1];
- DBG("NFC_AR_DO %zd", do_length);
+ DBG("NFC_AR_DO %zu", do_length);
rule_ptr += 2;
if (do_length != 1)
@@ -316,7 +316,7 @@ static struct seel_ace_rule *build_rule(struct seel_ace *ace,
switch (rule_ptr[0]) {
case REF_DO:
do_length = rule_ptr[1];
- DBG("REF_DO %zd", do_length);
+ DBG("REF_DO %zu", do_length);
rule_ptr += 2;
err = build_ref(ace_rule, rule_ptr, do_length);
@@ -330,7 +330,7 @@ static struct seel_ace_rule *build_rule(struct seel_ace *ace,
case AR_DO:
do_length = rule_ptr[1];
- DBG("AR_DO %zd", do_length);
+ DBG("AR_DO %zu", do_length);
rule_ptr += 2;
err = build_ar(ace_rule, rule_ptr, do_length);
@@ -378,7 +378,7 @@ static int build_ace_rules(struct seel_ace *ace,
remaining -= ref_ar_do_length + 2;
rule_ptr += 2;
- DBG("REF_AR_DO %zd bytes", ref_ar_do_length);
+ DBG("REF_AR_DO %zu bytes", ref_ar_do_length);
rule = build_rule(ace, rule_ptr, ref_ar_do_length);
if (!rule) {
@@ -412,7 +412,7 @@ static int ace_rule_length(uint8_t *apdu, size_t apdu_length,
if (length & 0x80) {
size_t _length = length & 0x7f, i, base;
- DBG("%zd", _length);
+ DBG("%zu", _length);
if (apdu_length < 3 + _length)
return -EINVAL;
@@ -441,7 +441,7 @@ static void get_next_gp_data_cb(void *context,
struct seel_ace *ace = context;
size_t payload_length;
- DBG("Current %zd Total %zd Got %zd",
+ DBG("Current %zu Total %zu Got %zu",
ace->current_rules_length, ace->rules_length, apdu_length);
if (err)
@@ -523,7 +523,7 @@ static void get_all_gp_data_cb(void *context,
payload_length = apdu_length - GET_ALL_DATA_CMD_LEN -
length_length - APDU_STATUS_LEN;
- DBG("Received %zd bytes of payload", payload_length);
+ DBG("Received %zu bytes of payload", payload_length);
if (payload_length < (size_t)rule_length) {
ace->rules_length = rule_length;
@@ -655,7 +655,7 @@ static struct seel_ace_rule *find_specific_rule(struct seel_ace *ace,
{
GSList *list;
- DBG("%zd", aid_len);
+ DBG("%zu", aid_len);
if (!hash || !aid)
return false;
@@ -684,7 +684,7 @@ static bool find_specific_rule_for_aid(struct seel_ace *ace,
{
GSList *list;
- DBG("%zd", aid_len);
+ DBG("%zu", aid_len);
if (!aid)
return false;
@@ -713,7 +713,7 @@ static struct seel_ace_rule *find_generic_rule_for_aid(struct seel_ace *ace,
{
GSList *list;
- DBG("%zd", aid_len);
+ DBG("%zu", aid_len);
if (!aid)
return false;
@@ -833,7 +833,7 @@ bool __seel_ace_apdu_allowed(struct seel_channel *channel, uint8_t *hash,
uint8_t *aid;
size_t aid_len;
- DBG("%zd", apdu_len);
+ DBG("%zu", apdu_len);
/* XXX Do we need to do some filtering on the basic channel ?*/
if (__seel_channel_is_basic(channel))
diff --git a/se/apdu.c b/se/apdu.c
index f5ba28f..fe0e631 100644
--- a/se/apdu.c
+++ b/se/apdu.c
@@ -131,7 +131,7 @@ struct seel_apdu *__seel_apdu_build(uint8_t *apdu, size_t length, uint8_t channe
}
if (channel > 3) {
- DBG("Invalid channel number %d", channel);
+ DBG("Invalid channel number %u", channel);
channel = 0;
}
@@ -159,7 +159,7 @@ void __seel_apdu_dump(uint8_t *apdu, size_t length)
sprintf(str + (3 * i), "%02X ", apdu[i]);
str[3 * length] = 0;
- DBG("[%zd] %s", length, str);
+ DBG("[%zu] %s", length, str);
g_free(str);
}
@@ -188,7 +188,7 @@ struct seel_apdu *__seel_apdu_open_logical_channel(void)
struct seel_apdu *__seel_apdu_close_logical_channel(uint8_t channel)
{
- DBG("%d", channel);
+ DBG("%u", channel);
return alloc_apdu(CLA_CHANNEL_STANDARD, 0, INS_MANAGE_CHANNEL, 0x80,
channel, 0, NULL, -1);
@@ -197,7 +197,7 @@ struct seel_apdu *__seel_apdu_close_logical_channel(uint8_t channel)
struct seel_apdu *__seel_apdu_select_aid(uint8_t channel,
uint8_t *aid, size_t aid_length)
{
- DBG("%zd", aid_length);
+ DBG("%zu", aid_length);
if (aid_length < MIN_AID_LENGTH ||
aid_length > MAX_AID_LENGTH)
diff --git a/se/plugins/nfc.c b/se/plugins/nfc.c
index 75aba3b..e2f5412 100644
--- a/se/plugins/nfc.c
+++ b/se/plugins/nfc.c
@@ -197,7 +197,7 @@ static int nfc_netlink_event_se(struct genlmsghdr *gnlh, bool add)
nfc_idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]);
se_idx = nla_get_u32(attrs[NFC_ATTR_SE_INDEX]);
- DBG("NFC %d SE %d", nfc_idx, se_idx);
+ DBG("NFC %u SE %u", nfc_idx, se_idx);
if (add) {
uint8_t se_type, seel_se_type;
@@ -209,7 +209,7 @@ static int nfc_netlink_event_se(struct genlmsghdr *gnlh, bool add)
se_type = nla_get_u8(attrs[NFC_ATTR_SE_TYPE]);
seel_se_type = nfc_se_type(se_type);
- DBG("NFC SE type %d %d", se_type, seel_se_type);
+ DBG("NFC SE type %u %u", se_type, seel_se_type);
return seel_manager_se_add(se_idx, nfc_idx, seel_se_type,
SEEL_CONTROLLER_NFC);
@@ -267,7 +267,7 @@ static int nfc_netlink_event_io(struct genlmsghdr *gnlh)
goto out;
}
- DBG("NFC %d SE %d APDU len %zd", nfc_idx, se_idx, apdu_len);
+ DBG("NFC %u SE %u APDU len %zu", nfc_idx, se_idx, apdu_len);
nfc_state->ctx->cb(nfc_state->ctx->context, apdu, apdu_len, 0);
@@ -550,7 +550,7 @@ static int nfc_transceive(uint8_t ctrl_idx, uint32_t se_idx,
void *hdr;
int err;
- DBG("%zd APDU %p", apdu_length, apdu);
+ DBG("%zu APDU %p", apdu_length, apdu);
if (nfc_state->ctx)
return -EALREADY;
diff --git a/se/plugins/tizen.c b/se/plugins/tizen.c
index 6bdbc24..e2ea4de 100644
--- a/se/plugins/tizen.c
+++ b/se/plugins/tizen.c
@@ -375,7 +375,7 @@ static void tapi_transfer_apdu_reply(DBusPendingCall *call, void *user_data)
if (apdu_length == 0 || apdu == NULL)
DBG("data is NULL");
- DBG("apdu_length %d", apdu_length);
+ DBG("apdu_length %u", apdu_length);
done:
ctx->cb(ctx->context, apdu, apdu_length, result);
diff --git a/se/se.c b/se/se.c
index 002498e..9a8b32e 100644
--- a/se/se.c
+++ b/se/se.c
@@ -116,7 +116,7 @@ static void io_cb(void *context,
struct seel_se_ioreq *req = context;
struct seel_se *se = req->se;
- DBG("%zd %d", apdu_length, err);
+ DBG("%zu %d", apdu_length, err);
/* Check response status */
if (!err)
@@ -247,7 +247,7 @@ static char *se_path(uint32_t se_idx, uint8_t ctrl_idx,
if (type == NULL)
return NULL;
- return g_strdup_printf("%s/se/%s%d_%s_se%d", SEEL_PATH,
+ return g_strdup_printf("%s/se/%s%u_%s_se%u", SEEL_PATH,
ctrl, ctrl_idx, type, se_idx);
}
@@ -538,7 +538,7 @@ static void open_channel_cb(void *context,
ctx->channel = apdu[0];
- DBG("Channel %d", ctx->channel);
+ DBG("Channel %u", ctx->channel);
select_aid = __seel_apdu_select_aid(ctx->channel,
ctx->aid, ctx->aid_len);