refactor: remove redefinition of byte, clean up more extern (#111)
diff --git a/test/context.c b/test/context.c
index 3f38d11..136323e 100644
--- a/test/context.c
+++ b/test/context.c
@@ -6,12 +6,11 @@
#include <assert.h>
#include <cn-cbor/cn-cbor.h>
+#include <cose/cose.h>
#ifdef USE_CBOR_CONTEXT
#include "context.h"
-typedef unsigned char byte;
-
typedef struct {
cn_cbor_context context;
byte *pFirst;
@@ -148,12 +147,11 @@
int IsContextEmpty(cn_cbor_context *pContext)
{
MyContext *myContext = (MyContext *)pContext;
- MyItem *p;
int i = 0;
// Walk memory and check every block
- for (p = (MyItem *)myContext->pFirst; p != NULL; p = p->pNext) {
+ for (MyItem *p = (MyItem *)myContext->pFirst; p != NULL; p = p->pNext) {
if (p->pad[0] == (byte)0xab) {
// Block has been freed
}
diff --git a/test/context.h b/test/context.h
index e258c4c..601c66b 100644
--- a/test/context.h
+++ b/test/context.h
@@ -2,7 +2,8 @@
#ifdef USE_CBOR_CONTEXT
-extern cn_cbor_context* CreateContext();
-extern void FreeContext(cn_cbor_context* pContext);
+cn_cbor_context* CreateContext();
+void FreeContext(cn_cbor_context* pContext);
+int IsContextEmpty(cn_cbor_context* pContext);
#endif // USE_CBOR_CONTEXT
diff --git a/test/mac_test.c b/test/mac_test.c
index 17021d7..d7cf060 100644
--- a/test/mac_test.c
+++ b/test/mac_test.c
@@ -3,14 +3,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include <cose/cose.h>
#include <cose/cose_configure.h>
#include <cn-cbor/cn-cbor.h>
#include "cose_int.h"
-#if INCLUDE_MAC && !INCLUDE_ENCRYPT0
-#include <cose_int.h>
-#endif
-
#include "json.h"
#include "test.h"
#include "context.h"
@@ -574,8 +571,6 @@
fprintf(stdout, "\r\n");
#endif
- /* */
-
int typ;
hEncObj = (HCOSE_MAC)COSE_Decode(
rgb, (int)cb, &typ, COSE_mac_object, CBOR_CONTEXT_PARAM_COMMA NULL);
diff --git a/test/test.h b/test/test.h
index 19a402f..300ee96 100644
--- a/test/test.h
+++ b/test/test.h
@@ -2,6 +2,9 @@
#include <stdbool.h>
+#include "cose/cose.h"
+#include "context.h"
+
#ifdef USE_CBOR_CONTEXT
cn_cbor_context* context;
#define CBOR_CONTEXT_PARAM , context
@@ -43,13 +46,6 @@
void MAC_Corners();
void MAC0_Corners();
-#ifdef USE_CBOR_CONTEXT
-// context.c
-extern cn_cbor_context* CreateContext(unsigned int iFailPoint);
-void FreeContext(cn_cbor_context* pContext);
-int IsContextEmpty(cn_cbor_context* pContext);
-#endif
-
// test.c
enum {
Attributes_MAC_protected = 1,