Skip to contentSkip to conversation

env_ubi.c: Correct pointer error in env load

PATCH New Kevin Smith 3 participants 3 messages Oct 23, 2015 – Oct 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 env_ubi.c: Correct pointer error in env load

The variable "buf" in this function is a char array, and the function ubi_volume_read is expecting a char *. In the call, the address of the pointer is being taken, incorrectly passing a char **. The compiler warning was being silenced by the cast. Remove the address operator and the cast.

Cc Joe Hershberger <[email protected]>
Cc Tom Rini <[email protected]>
---
 common/env_ubi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
common/env_ubi.c +1 -2
index e0dc5af..e611199 100644
@@ -181,8 +181,7 @@ void env_relocate_spec(void)
 		return;
 	}
 
-	if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)&buf,
-			    CONFIG_ENV_SIZE)) {
+	if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, CONFIG_ENV_SIZE)) {
 		printf("\n** Unable to read env from %s:%s **\n",
 		       CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
 		set_default_env(NULL);
Signature · 1 line
2.4.6
#1 lore raw

PATCH 1/1 env_ubi.c: Correct pointer error in env load

Quoted 9 lines · Kevin Smith

The variable "buf" in this function is a char array, and the function ubi_volume_read is expecting a char *. In the call, the address of the pointer is being taken, incorrectly passing a char **. The compiler warning was being silenced by the cast. Remove the address operator and the cast.

Cc Joe Hershberger <[email protected]>
Cc Tom Rini <[email protected]>
#2 lore raw

PATCH 1/1 env_ubi.c: Correct pointer error in env load

In reply to Kevin Smith

Hello Kevin,

Am 23.10.2015 um 19:51 schrieb Kevin Smith:

Quoted 18 lines

The variable "buf" in this function is a char array, and the function ubi_volume_read is expecting a char *. In the call, the address of the pointer is being taken, incorrectly passing a char **. The compiler warning was being silenced by the cast. Remove the address operator and the cast.

Cc Joe Hershberger <[email protected]>
Cc Tom Rini <[email protected]>
---
  common/env_ubi.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
common/env_ubi.c +0 -0
index e0dc5af..e611199 100644

common/env_ubi.c void env_relocate_spec(void) · line 187

Quoted 9 lines
common/env_ubi.c +1 -2
@@ -181,8 +181,7 @@ void env_relocate_spec(void)
  		return;
  	}
 
-	if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)&buf,
-			    CONFIG_ENV_SIZE)) {
+	if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, CONFIG_ENV_SIZE)) {
  		printf("\n** Unable to read env from %s:%s **\n",
  		       CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
  		set_default_env(NULL);

Good catch!

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany