[Spice-devel] [cacard 1/5] hex_dump: Remove unused arguments
Christophe Fergeau
cfergeau at redhat.com
Tue Aug 21 15:03:54 UTC 2018
hex_dump() callers can theoretically provide the destination buffer
for the hexdump'ed string, but nothing in libcacard uses that feature.
This commit removes it.
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
src/cac-aca.c | 10 +++++-----
src/cac.c | 8 ++++----
src/common.c | 19 +++++--------------
src/common.h | 3 +--
4 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/src/cac-aca.c b/src/cac-aca.c
index 8a985ee..3e1cb35 100644
--- a/src/cac-aca.c
+++ b/src/cac-aca.c
@@ -1081,7 +1081,7 @@ cac_aca_get_acr_response_extended(VCard *card, int Le, unsigned char *acrid)
r = vcard_response_new(card, buffer, buffer_len, Le,
VCARD7816_STATUS_SUCCESS);
g_debug("%s: response bytes: %s", __func__,
- hex_dump(buffer, buffer_len, NULL, 0));
+ hex_dump(buffer, buffer_len));
g_free(buffer);
return r;
}
@@ -1163,7 +1163,7 @@ cac_aca_get_applet_acr_response_simpletlv(VCard *card, int Le,
/* Prepare the SimpleTLV structures */
properties = cac_aca_get_properties(&properties_len);
if (coid != NULL) {
- g_debug("%s: Called. COID = %s", __func__, hex_dump(coid, 2, NULL, 0));
+ g_debug("%s: Called. COID = %s", __func__, hex_dump(coid, 2));
/* getting the table for Card Object ID (2B) */
acr_len = 1; // returns exactly one element if found
@@ -1199,7 +1199,7 @@ cac_aca_get_applet_acr_response_simpletlv(VCard *card, int Le,
r = vcard_response_new(card, acr_buffer, acr_buffer_len, Le,
VCARD7816_STATUS_SUCCESS);
g_debug("%s: response bytes: %s", __func__,
- hex_dump(acr_buffer, acr_buffer_len, NULL, 0));
+ hex_dump(acr_buffer, acr_buffer_len));
failure:
g_free(list);
@@ -1293,7 +1293,7 @@ cac_aca_get_applet_acr_response_extended(VCard *card, int Le,
r = vcard_response_new(card, buffer, buffer_len, Le,
VCARD7816_STATUS_SUCCESS);
g_debug("%s: response bytes: %s", __func__,
- hex_dump(buffer, buffer_len, NULL, 0));
+ hex_dump(buffer, buffer_len));
failure:
g_free(buffer);
return r;
@@ -1427,7 +1427,7 @@ cac_aca_get_service_response_extended(VCard *card, int Le,
r = vcard_response_new(card, buffer, buffer_len, Le,
VCARD7816_STATUS_SUCCESS);
g_debug("%s: response bytes: %s", __func__,
- hex_dump(buffer, buffer_len, NULL, 0));
+ hex_dump(buffer, buffer_len));
g_free(buffer);
return r;
}
diff --git a/src/cac.c b/src/cac.c
index c3c9dd9..c95488f 100644
--- a/src/cac.c
+++ b/src/cac.c
@@ -964,7 +964,7 @@ cac_new_pki_applet_private(int i, const unsigned char *cert,
goto failure;
}
g_debug("%s: applet_private->tag_buffer = %s", __func__,
- hex_dump(applet_private->tag_buffer, applet_private->tag_buffer_len, NULL, 0));
+ hex_dump(applet_private->tag_buffer, applet_private->tag_buffer_len));
/* Value buffer */
/* Ex:
@@ -981,7 +981,7 @@ cac_new_pki_applet_private(int i, const unsigned char *cert,
goto failure;
}
g_debug("%s: applet_private->val_buffer = %s", __func__,
- hex_dump(applet_private->val_buffer, applet_private->val_buffer_len, NULL, 0));
+ hex_dump(applet_private->val_buffer, applet_private->val_buffer_len));
/* Inject Object ID */
object_id[1] = i;
@@ -1681,7 +1681,7 @@ cac_new_ccc_applet_private(int cert_count)
if (applet_private->tag_buffer_len == 0)
goto failure;
g_debug("%s: applet_private->tag_buffer = %s", __func__,
- hex_dump(applet_private->tag_buffer, applet_private->tag_buffer_len, NULL, 0));
+ hex_dump(applet_private->tag_buffer, applet_private->tag_buffer_len));
/* Value buffer */
/* Ex:
@@ -1723,7 +1723,7 @@ cac_new_ccc_applet_private(int cert_count)
if (applet_private->val_buffer_len == 0)
goto failure;
g_debug("%s: applet_private->val_buffer = %s", __func__,
- hex_dump(applet_private->val_buffer, applet_private->val_buffer_len, NULL, 0));
+ hex_dump(applet_private->val_buffer, applet_private->val_buffer_len));
/* Inject Object ID */
tv_object[0].value.value = object_id;
diff --git a/src/common.c b/src/common.c
index bc9a43f..6f835df 100644
--- a/src/common.c
+++ b/src/common.c
@@ -52,29 +52,20 @@ lebytes2ushort(const unsigned char *buf)
static char hexdump_buffer[5*MAX_STATIC_BYTES];
/*
* Creates printable representation in hexadecimal format of the data
- * provided in the buf buffer. If out buffer is provided, the data
- * will be written into it. Otherwise, static buffer will be used, which
+ * provided in the buf buffer. A static buffer will be used, which
* can hold up to 1024 bytes (longer will get truncated).
*/
char *
-hex_dump(unsigned char *buf, size_t buflen, unsigned char **out, size_t outlen)
+hex_dump(unsigned char *buf, size_t buflen)
{
char *p, *start;
- size_t i, expect_len = buflen*5;
+ size_t i;
if (buflen <= 0)
return NULL;
- if (out == NULL) {
- start = hexdump_buffer;
- buflen = MIN(buflen, MAX_STATIC_BYTES);
- } else {
- if (outlen < expect_len) {
- /* too short output buffer */
- return NULL;
- }
- start = (char *) *out;
- }
+ start = hexdump_buffer;
+ buflen = MIN(buflen, MAX_STATIC_BYTES);
p = start;
for (i = 0; i < buflen; i++) {
diff --git a/src/common.h b/src/common.h
index 23ac91f..0336273 100644
--- a/src/common.h
+++ b/src/common.h
@@ -29,7 +29,6 @@
unsigned char *ushort2lebytes(unsigned char *buf, unsigned short x);
unsigned short lebytes2ushort(const unsigned char *buf);
-char *hex_dump(unsigned char *buf, size_t buflen,
- unsigned char **out, size_t outlen);
+char *hex_dump(unsigned char *buf, size_t buflen);
#endif
--
2.17.1
More information about the Spice-devel
mailing list