Skip to contentSkip to conversation

avb: Fix build when CONFIG_OPTEE_TA_AVB is disabled

PATCH New Sam Protsenko 3 participants 7 messages Jul 31, 2019 – Aug 8, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 avb: Fix build when CONFIG_OPTEE_TA_AVB is disabled

When having only these AVB related configs enabled:

CONFIG_AVB_VERIFY=y
CONFIG_CMD_AVB=y
CONFIG_LIBAVB=y

build fails with next errors:

common/avb_verify.c: In function 'read_persistent_value':
common/avb_verify.c:867:6: warning: implicit declaration of function
'get_open_session'
common/avb_verify.c:870:45: error: 'struct AvbOpsData' has no member
named 'tee'
common/avb_verify.c:894:7: warning: implicit declaration of function
'invoke_func'
common/avb_verify.c: In function 'write_persistent_value':
common/avb_verify.c:931:45: error: 'struct AvbOpsData' has no member
named 'tee'

Guard read_persistent_value() and write_persistent_value() functions by checking if CONFIG_OPTEE_TA_AVB is enabled (as those are only used in that case) to fix the build with mentioned configuration.

---
 common/avb_verify.c | 3 +++
 1 file changed, 3 insertions(+)
common/avb_verify.c +3 -0
index 32034d927c..36898a610f 100644
@@ -851,6 +851,7 @@ static AvbIOResult get_size_of_partition(AvbOps *ops,
 	return AVB_IO_RESULT_OK;
 }
 
+#ifdef CONFIG_OPTEE_TA_AVB
 static AvbIOResult read_persistent_value(AvbOps *ops,
 					 const char *name,
 					 size_t buffer_size,
@@ -968,6 +969,8 @@ free_name:
 
 	return rc;
 }
+#endif
+
 /**
  * ============================================================================
  * AVB2.0 AvbOps alloc/initialisation/free
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 cmd: avb: Fix compiler warnings

When building U-Boot with AVB enabled, compiler shows next warnings:

cmd/avb.c: In function 'do_avb_read_pvalue':
cmd/avb.c:371:18: warning: format '%ld' expects argument of type
'long int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
printf("Read %ld bytes, value = %s\n", bytes_read,
~~^ ~~~~~~~~~~
%d

cmd/avb.c: In function 'do_avb_write_pvalue':
cmd/avb.c:404:19: warning: format '%ld' expects argument of type
'long int', but argument 2 has type '__kernel_size_t' {aka 'unsigned int'} [-Wformat=]
printf("Wrote %ld bytes\n", strlen(value) + 1);
~~^ ~~~~~~~~~~~~~~~~~
%d

Fix those by using "%zu" specified.

---
 cmd/avb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
cmd/avb.c +2 -2
index c5af4a2e46..3f6fd763a0 100644
@@ -368,7 +368,7 @@ int do_avb_read_pvalue(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	if (avb_ops->read_persistent_value(avb_ops, name, bytes, buffer,
 					   &bytes_read) == AVB_IO_RESULT_OK) {
-		printf("Read %ld bytes, value = %s\n", bytes_read,
+		printf("Read %zu bytes, value = %s\n", bytes_read,
 		       (char *)buffer);
 		free(buffer);
 		return CMD_RET_SUCCESS;
@@ -401,7 +401,7 @@ int do_avb_write_pvalue(cmd_tbl_t *cmdtp, int flag, int argc,
 	if (avb_ops->write_persistent_value(avb_ops, name, strlen(value) + 1,
 					    (const uint8_t *)value) ==
 	    AVB_IO_RESULT_OK) {
-		printf("Wrote %ld bytes\n", strlen(value) + 1);
+		printf("Wrote %zu bytes\n", strlen(value) + 1);
 		return CMD_RET_SUCCESS;
 	}
 
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 cmd: avb: Fix compiler warnings

Hi,

Quoted 49 lines · Sam Protsenko

When building U-Boot with AVB enabled, compiler shows next warnings:

cmd/avb.c: In function 'do_avb_read_pvalue':
cmd/avb.c:371:18: warning: format '%ld' expects argument of type
'long int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
printf("Read %ld bytes, value = %s\n", bytes_read,
~~^ ~~~~~~~~~~
%d

cmd/avb.c: In function 'do_avb_write_pvalue':
cmd/avb.c:404:19: warning: format '%ld' expects argument of type
'long int', but argument 2 has type '__kernel_size_t' {aka 'unsigned int'} [-Wformat=]
printf("Wrote %ld bytes\n", strlen(value) + 1);
~~^ ~~~~~~~~~~~~~~~~~
%d

Fix those by using "%zu" specified.

---
 cmd/avb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
cmd/avb.c +2 -3
index c5af4a2e46..3f6fd763a0 100644
@@ -368,7 +368,7 @@ int do_avb_read_pvalue(cmd_tbl_t *cmdtp, int flag, int argc,
 
        if (avb_ops->read_persistent_value(avb_ops, name, bytes, buffer,
                                           &bytes_read) == AVB_IO_RESULT_OK) {
-               printf("Read %ld bytes, value = %s\n", bytes_read,
+               printf("Read %zu bytes, value = %s\n", bytes_read,
                       (char *)buffer);
                free(buffer);
                return CMD_RET_SUCCESS;
@@ -401,7 +401,7 @@ int do_avb_write_pvalue(cmd_tbl_t *cmdtp, int flag, int argc,
        if (avb_ops->write_persistent_value(avb_ops, name, strlen(value) + 1,
                                            (const uint8_t *)value) ==
            AVB_IO_RESULT_OK) {
-               printf("Wrote %ld bytes\n", strlen(value) + 1);
+               printf("Wrote %zu bytes\n", strlen(value) + 1);
                return CMD_RET_SUCCESS;
        }
 
--
Quoted 2 lines

2.20.1

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#3 lore raw

PATCH 2/2 cmd: avb: Fix compiler warnings

In reply to Sam Protsenko
Quoted 18 lines · Sam Protsenko

When building U-Boot with AVB enabled, compiler shows next warnings:

cmd/avb.c: In function 'do_avb_read_pvalue':
cmd/avb.c:371:18: warning: format '%ld' expects argument of type
'long int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
printf("Read %ld bytes, value = %s\n", bytes_read,
~~^ ~~~~~~~~~~
%d

cmd/avb.c: In function 'do_avb_write_pvalue':
cmd/avb.c:404:19: warning: format '%ld' expects argument of type
'long int', but argument 2 has type '__kernel_size_t' {aka 'unsigned int'} [-Wformat=]
printf("Wrote %ld bytes\n", strlen(value) + 1);
~~^ ~~~~~~~~~~~~~~~~~
%d

Quoted 4 lines

Fix those by using "%zu" specified.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190807/95beeefa/attachment.sig>
#4 lore raw

PATCH 1/2 avb: Fix build when CONFIG_OPTEE_TA_AVB is disabled

In reply to Sam Protsenko

Hi,

Quoted 51 lines · Sam Protsenko

When having only these AVB related configs enabled:

CONFIG_AVB_VERIFY=y
CONFIG_CMD_AVB=y
CONFIG_LIBAVB=y

build fails with next errors:

common/avb_verify.c: In function 'read_persistent_value':
common/avb_verify.c:867:6: warning: implicit declaration of function
'get_open_session'
common/avb_verify.c:870:45: error: 'struct AvbOpsData' has no member
named 'tee'
common/avb_verify.c:894:7: warning: implicit declaration of function
'invoke_func'
common/avb_verify.c: In function 'write_persistent_value':
common/avb_verify.c:931:45: error: 'struct AvbOpsData' has no member
named 'tee'

Guard read_persistent_value() and write_persistent_value() functions by checking if CONFIG_OPTEE_TA_AVB is enabled (as those are only used in that case) to fix the build with mentioned configuration.

---
 common/avb_verify.c | 3 +++
 1 file changed, 3 insertions(+)
common/avb_verify.c +3 -1
index 32034d927c..36898a610f 100644
@@ -851,6 +851,7 @@ static AvbIOResult get_size_of_partition(AvbOps *ops,
        return AVB_IO_RESULT_OK;
 }
 
+#ifdef CONFIG_OPTEE_TA_AVB
 static AvbIOResult read_persistent_value(AvbOps *ops,
                                         const char *name,
                                         size_t buffer_size,
@@ -968,6 +969,8 @@ free_name:
 
        return rc;
 }
+#endif
+
 /**
  * ============================================================================
  * AVB2.0 AvbOps alloc/initialisation/free
--
Quoted 2 lines

2.20.1

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#5 lore raw

PATCH 1/2 avb: Fix build when CONFIG_OPTEE_TA_AVB is disabled

Hi Tom,

Quoted 48 lines · Igor Opaniuk

Hi,

Quoted 43 lines · Sam Protsenko

When having only these AVB related configs enabled:

CONFIG_AVB_VERIFY=y
CONFIG_CMD_AVB=y
CONFIG_LIBAVB=y

build fails with next errors:

common/avb_verify.c: In function 'read_persistent_value':
common/avb_verify.c:867:6: warning: implicit declaration of function
'get_open_session'
common/avb_verify.c:870:45: error: 'struct AvbOpsData' has no member
named 'tee'
common/avb_verify.c:894:7: warning: implicit declaration of function
'invoke_func'
common/avb_verify.c: In function 'write_persistent_value':
common/avb_verify.c:931:45: error: 'struct AvbOpsData' has no member
named 'tee'

Guard read_persistent_value() and write_persistent_value() functions by checking if CONFIG_OPTEE_TA_AVB is enabled (as those are only used in that case) to fix the build with mentioned configuration.

---
 common/avb_verify.c | 3 +++
 1 file changed, 3 insertions(+)
common/avb_verify.c +1 -0
index 32034d927c..36898a610f 100644
@@ -851,6 +851,7 @@ static AvbIOResult get_size_of_partition(AvbOps *ops,
        return AVB_IO_RESULT_OK;
 }
 
+#ifdef CONFIG_OPTEE_TA_AVB
 static AvbIOResult read_persistent_value(AvbOps *ops,
                                         const char *name,
                                         size_t buffer_size,
@@ -968,6 +969,8 @@ free_name:
 
Quoted 13 lines
Quoted 10 lines
common/avb_verify.c +2 -1
        return rc;
 }
+#endif
+
 /**
  * ============================================================================
  * AVB2.0 AvbOps alloc/initialisation/free
--

2.20.1

Can you please pull this series (2 patches) to -rc2? It fixes the build with AVB enabled.

Thanks!

Quoted 9 lines

--
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk

#6 lore raw

PATCH 1/2 avb: Fix build when CONFIG_OPTEE_TA_AVB is disabled

In reply to Sam Protsenko
Quoted 19 lines · Sam Protsenko

When having only these AVB related configs enabled:

CONFIG_AVB_VERIFY=y
CONFIG_CMD_AVB=y
CONFIG_LIBAVB=y

build fails with next errors:

common/avb_verify.c: In function 'read_persistent_value':
common/avb_verify.c:867:6: warning: implicit declaration of function
'get_open_session'
common/avb_verify.c:870:45: error: 'struct AvbOpsData' has no member
named 'tee'
common/avb_verify.c:894:7: warning: implicit declaration of function
'invoke_func'
common/avb_verify.c: In function 'write_persistent_value':
common/avb_verify.c:931:45: error: 'struct AvbOpsData' has no member
named 'tee'

Quoted 6 lines

Guard read_persistent_value() and write_persistent_value() functions by checking if CONFIG_OPTEE_TA_AVB is enabled (as those are only used in that case) to fix the build with mentioned configuration.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190807/ab4dec19/attachment.sig>