1From ba44b87318ed89e489fa3ce0a5d66002afa2bd6c Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Fri, 12 Aug 2022 11:54:54 +0200
4Subject: [PATCH] src/p11_attr.c: fix build with gcc 4.8
5
6Fix the following build failure with gcc 4.8 raised since version 0.4.12
7and
8https://github.com/OpenSC/libp11/commit/639a4b6463278c0119a2ec60b261da3e5330fb33:
9
10p11_attr.c: In function 'pkcs11_zap_attrs':
11p11_attr.c:167:2: error: 'for' loop initial declarations are only allowed in C99 mode
12  for (unsigned i = 0; i < 32; i++) {
13  ^
14p11_attr.c:167:2: note: use option -std=c99 or -std=gnu99 to compile your code
15
16Fixes:
17 - http://autobuild.buildroot.org/results/4391020fb5738cc8c26dc53783a6228bbf76473a
18
19Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
20[Retrieved from:
21https://github.com/OpenSC/libp11/commit/ba44b87318ed89e489fa3ce0a5d66002afa2bd6c]
22---
23 src/p11_attr.c | 4 +++-
24 1 file changed, 3 insertions(+), 1 deletion(-)
25
26diff --git a/src/p11_attr.c b/src/p11_attr.c
27index d49456ff..d425241a 100644
28--- a/src/p11_attr.c
29+++ b/src/p11_attr.c
30@@ -162,9 +162,11 @@ void pkcs11_addattr_obj(PKCS11_TEMPLATE *tmpl, int type, pkcs11_i2d_fn enc, void
31
32 void pkcs11_zap_attrs(PKCS11_TEMPLATE *tmpl)
33 {
34+	unsigned int i;
35+
36 	if (!tmpl->allocated)
37 		return;
38-	for (unsigned i = 0; i < 32; i++) {
39+	for (i = 0; i < 32; i++) {
40 		if (tmpl->allocated & (1<<i))
41 			OPENSSL_free(tmpl->attrs[i].pValue);
42 	}
43