From 99b5cb53e1da2f0d7692f28dceff8485d4b74daf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?=
 <ng.hong.quan@gmail.com>
Date: Wed, 10 Dec 2014 03:59:54 +0800
Subject: [PATCH 1/2] OpenPGP: Remove unused variables and fix type cast.

---
 src/libopensc/card-openpgp.c | 10 +++-------
 src/tools/openpgp-tool.c     |  4 +---
 2 files changed, 4 insertions(+), 10 deletions(-)

Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -1966,8 +1966,6 @@ static int pgp_update_card_algorithms(sc
  **/
 static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
 {
-	struct pgp_priv_data *priv = DRVDATA(card);
-	pgp_blob_t *algo_blob;
 	sc_apdu_t apdu;
 	/* Temporary variables to hold APDU params */
 	u8 apdu_case;
@@ -2396,10 +2394,9 @@ static int pgp_erase_card(sc_card_t *car
 		{0, 0x44, 0, 0}
 	};
 	u8 apdu_lens[10] = {13, 13, 13, 13, 13, 13, 13, 13, 4, 4};
-	u8 buf[SC_MAX_APDU_BUFFER_SIZE];
 	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 	sc_apdu_t apdu;
-	int i, l, r;
+	u8 i, l, r;
 
 	LOG_FUNC_CALLED(ctx);
 
@@ -2478,7 +2475,7 @@ gnuk_delete_key(sc_card_t *card, u8 key_
 {
 	sc_context_t *ctx = card->ctx;
 	int r = SC_SUCCESS;
-	u8 *data = NULL;
+	char *data = NULL;
 
 	LOG_FUNC_CALLED(ctx);
 
@@ -2506,7 +2503,7 @@ gnuk_delete_key(sc_card_t *card, u8 key_
 	else if (key_id == 3)
 		data = "\x4D\x02\xA4";
 
-	r = pgp_put_data(card, 0x4D, data, strlen(data) + 1);
+	r = pgp_put_data(card, 0x4D, (const u8 *)data, strlen((const char *)data) + 1);
 
 	LOG_FUNC_RETURN(ctx, r);
 }
@@ -2519,7 +2516,6 @@ pgp_delete_file(sc_card_t *card, const s
 	struct pgp_priv_data *priv = DRVDATA(card);
 	pgp_blob_t *blob;
 	sc_file_t *file;
-	u8 key_id;
 	int r;
 
 	LOG_FUNC_CALLED(card->ctx);
Index: opensc-20150513/src/tools/openpgp-tool.c
===================================================================
--- opensc-20150513.orig/src/tools/openpgp-tool.c
+++ opensc-20150513/src/tools/openpgp-tool.c
@@ -473,7 +473,6 @@ int do_verify(sc_card_t *card, char *typ
  **/
 int delete_key_openpgp(sc_card_t *card, u8 key_id)
 {
-	sc_context_t *ctx = card->ctx;
 	char *del_fingerprint = "00:DA:00:C6:14:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00";
 	char *del_creationtime = "00:DA:00:CD:04:00:00:00:00";
 	/* We need to replace the 4th byte later */
@@ -520,7 +519,6 @@ int delete_key_openpgp(sc_card_t *card,
 
 int do_delete_key(sc_card_t *card, u8 key_id)
 {
-	sc_context_t *ctx = card->ctx;
 	sc_path_t path;
 	int r = SC_SUCCESS;
 
