From 83288efc7d1b673d30edee6ce732d1de8c505da3 Mon Sep 17 00:00:00 2001
From: "henryk@ploetzli.ch"
 <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Date: Sat, 5 Sep 2009 22:17:18 +0000
Subject: [PATCH] Remove unused code from hitag2.c Mark intermittently used
 code in iso15693.c as attribute unused Change CFLAGS to -Werror to enforce
 warning free code

---
 armsrc/hitag2.c        | 46 ------------------------------------------
 armsrc/iso15693.c      | 10 ++++-----
 common/Makefile.common |  2 +-
 3 files changed, 6 insertions(+), 52 deletions(-)

diff --git a/armsrc/hitag2.c b/armsrc/hitag2.c
index 26ab1066..886e1970 100644
--- a/armsrc/hitag2.c
+++ b/armsrc/hitag2.c
@@ -242,52 +242,6 @@ static u64 _hitag2_round (u64 *state)
 	return _f20 (x);
 }
 
-// Bitslice Hitag2 functions:
-
-#define ht2bs_4a(a,b,c,d)	(~(((a|b)&c)^(a|d)^b))
-#define ht2bs_4b(a,b,c,d)	(~(((d|c)&(a^b))^(d|a|b)))
-#define ht2bs_5c(a,b,c,d,e)	(~((((((c^e)|d)&a)^b)&(c^b))^(((d^e)|a)&((d^b)|c))))
-
-#define uf20bs				u32		// choose your own type/width
-
-static uf20bs _f20bs (const uf20bs *x)
-{
-	return ht2bs_5c (
-		ht2bs_4a(x[ 1],x[ 2],x[ 4],x[ 5]),
-		ht2bs_4b(x[ 7],x[11],x[13],x[14]),
-		ht2bs_4b(x[16],x[20],x[22],x[25]),
-		ht2bs_4b(x[27],x[28],x[30],x[32]),
-		ht2bs_4a(x[33],x[42],x[43],x[45]));
-}
-
-static void _hitag2bs_init (uf20bs *x, const uf20bs *key, const uf20bs *serial, const uf20bs *IV)
-{
-	u32					i, r;
-	
-	for (i = 0; i < 32; i++) x[i] = serial[i];
-	for (i = 0; i < 16; i++) x[32+i] = key[i];
-	
-	for (r = 0; r < 32; r++)
-	{
-		for (i = 0; i < 47; i++) x[i] = x[i+1];
-		x[47] = _f20bs (x) ^ IV[i] ^ key[16+i];
-	}
-}
-
-static uf20bs _hitag2bs_round (uf20bs *x)
-{
-	uf20bs				y;
-	u32					i;
-	
-	y = x[ 0] ^ x[ 2] ^ x[ 3] ^ x[ 6] ^ x[ 7] ^ x[ 8] ^ x[16] ^ x[22]
-	  ^ x[23] ^ x[26] ^ x[30] ^ x[41] ^ x[42] ^ x[43] ^ x[46] ^ x[47];
-	
-	for (i = 0; i < 47; i++) x[i] = x[i+1];
-	x[47] = y;
-	
-	return _f20bs (x);
-}
-
 static u32 _hitag2_byte (u64 * x)
 {
 	u32					i, c;
diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c
index 62e480c2..a80e6c6a 100644
--- a/armsrc/iso15693.c
+++ b/armsrc/iso15693.c
@@ -236,7 +236,7 @@ static void BuildIdentifyRequest(void)
 	CodeIso15693AsReader(cmd, sizeof(cmd));
 }
 
-static void BuildSysInfoRequest(BYTE *uid)
+static void __attribute__((unused)) BuildSysInfoRequest(BYTE *uid)
 {
 	BYTE cmd[12];
 
@@ -304,7 +304,7 @@ static void BuildSelectRequest( BYTE uid[])
 	CodeIso15693AsReader(cmd, sizeof(cmd));
 }
 
-static void BuildReadBlockRequest(BYTE *uid, BYTE blockNumber )
+static void __attribute__((unused)) BuildReadBlockRequest(BYTE *uid, BYTE blockNumber )
 {
 	BYTE cmd[13];
 
@@ -335,7 +335,7 @@ static void BuildReadBlockRequest(BYTE *uid, BYTE blockNumber )
 	CodeIso15693AsReader(cmd, sizeof(cmd));
 }
 
-static void BuildReadMultiBlockRequest(BYTE *uid)
+static void __attribute__((unused)) BuildReadMultiBlockRequest(BYTE *uid)
 {
 	BYTE cmd[14];
 
@@ -368,7 +368,7 @@ static void BuildReadMultiBlockRequest(BYTE *uid)
 	CodeIso15693AsReader(cmd, sizeof(cmd));
 }
 
-static void BuildArbitraryRequest(BYTE *uid,BYTE CmdCode)
+static void __attribute__((unused)) BuildArbitraryRequest(BYTE *uid,BYTE CmdCode)
 {
 	BYTE cmd[14];
 
@@ -402,7 +402,7 @@ static void BuildArbitraryRequest(BYTE *uid,BYTE CmdCode)
 	CodeIso15693AsReader(cmd, sizeof(cmd));
 }
 
-static void BuildArbitraryCustomRequest(BYTE uid[], BYTE CmdCode)
+static void __attribute__((unused)) BuildArbitraryCustomRequest(BYTE uid[], BYTE CmdCode)
 {
 	BYTE cmd[14];
 
diff --git a/common/Makefile.common b/common/Makefile.common
index c212ccb7..144bee43 100644
--- a/common/Makefile.common
+++ b/common/Makefile.common
@@ -54,7 +54,7 @@ VPATH = . ../common/ ../fpga/
 
 INCLUDES = ../include/proxmark3.h ../include/at91sam7s128.h ../include/config_gpio.h ../include/usb_cmd.h $(APP_INCLUDES)
 
-CFLAGS =  -c $(INCLUDE) -Wall $(APP_CFLAGS)
+CFLAGS =  -c $(INCLUDE) -Werror -pedantic -std=gnu99 $(APP_CFLAGS)
 
 THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
 ARMOBJ   = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC))
-- 
2.39.5