diff mbox series

uboot: output error string on failure

Message ID 20171006094529.12292-1-romain.bazile@ubiant.com
State Accepted
Headers show
Series uboot: output error string on failure | expand

Commit Message

Romain Bazile Oct. 6, 2017, 9:45 a.m. UTC
Makes the error easier to debug with the output of the error string

Signed-off-by: Romain Bazile <romain.bazile@ubiant.com>
---
 bootloader/uboot.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Stefano Babic Oct. 6, 2017, 11:08 a.m. UTC | #1
Hi Romain,

On 06/10/2017 11:45, Romain Bazile wrote:
> Makes the error easier to debug with the output of the error string
> 
> Signed-off-by: Romain Bazile <romain.bazile@ubiant.com>
> ---
>  bootloader/uboot.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/bootloader/uboot.c b/bootloader/uboot.c
> index 3b5a5ad..3697fe6 100644
> --- a/bootloader/uboot.c
> +++ b/bootloader/uboot.c
> @@ -47,11 +47,11 @@ static int lock_uboot_env(void)
>  	int lockfd = -1;
>  	lockfd = open(lockname, O_WRONLY | O_CREAT | O_TRUNC, 0666);
>  	if (lockfd < 0) {
> -		ERROR("Error opening U-Boot lock file %s\n", lockname);
> +		ERROR("Error opening U-Boot lock file %s, %s\n", lockname, strerror(errno));
>  		return -1;
>  	}
>  	if (flock(lockfd, LOCK_EX) < 0) {
> -		ERROR("Error locking file %s\n", lockname);
> +		ERROR("Error locking file %s, %s\n", lockname, strerror(errno));
>  		close(lockfd);
>  		return -1;
>  	}
> @@ -74,7 +74,7 @@ int bootloader_env_set(const char *name, const char *value)
>  		return -1;
>  
>  	if (fw_env_open (fw_env_opts)) {
> -		ERROR("Error: environment not initialized\n");
> +		ERROR("Error: environment not initialized, %s\n", strerror(errno));
>  		unlock_uboot_env(lock);
>  		return -1;
>  	}
> @@ -103,7 +103,7 @@ char *bootloader_env_get(const char *name)
>  		return NULL;
>  
>  	if (fw_env_open (fw_env_opts)) {
> -		ERROR("Error: environment not initialized\n");
> +		ERROR("Error: environment not initialized, %s\n", strerror(errno));
>  		unlock_uboot_env(lock);
>  		return NULL;
>  	}
> @@ -126,7 +126,7 @@ int bootloader_apply_list(const char *filename)
>  
>  	lockfd = lock_uboot_env();
>  	if (lockfd < 0) {
> -		ERROR("Error opening U-Boot lock file %s\n", lockname);
> +		ERROR("Error opening U-Boot lock file %s, %s\n", lockname, strerror(errno));
>  		return -ENODEV;
>  	}
>  

Your and other patches are proofing that I economized with the error ouput..

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Romain Bazile Oct. 6, 2017, 12:29 p.m. UTC | #2
I guess that's what we all do until we actually need more information 
for debugging!


Romain Bazile
Hardware R&D Engineer
ubiant

Le 06/10/2017 à 13:08, Stefano Babic a écrit :
> Hi Romain,
> 
> On 06/10/2017 11:45, Romain Bazile wrote:
>> Makes the error easier to debug with the output of the error string
>>
>> Signed-off-by: Romain Bazile <romain.bazile@ubiant.com>
>> ---
>>   bootloader/uboot.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/bootloader/uboot.c b/bootloader/uboot.c
>> index 3b5a5ad..3697fe6 100644
>> --- a/bootloader/uboot.c
>> +++ b/bootloader/uboot.c
>> @@ -47,11 +47,11 @@ static int lock_uboot_env(void)
>>   	int lockfd = -1;
>>   	lockfd = open(lockname, O_WRONLY | O_CREAT | O_TRUNC, 0666);
>>   	if (lockfd < 0) {
>> -		ERROR("Error opening U-Boot lock file %s\n", lockname);
>> +		ERROR("Error opening U-Boot lock file %s, %s\n", lockname, strerror(errno));
>>   		return -1;
>>   	}
>>   	if (flock(lockfd, LOCK_EX) < 0) {
>> -		ERROR("Error locking file %s\n", lockname);
>> +		ERROR("Error locking file %s, %s\n", lockname, strerror(errno));
>>   		close(lockfd);
>>   		return -1;
>>   	}
>> @@ -74,7 +74,7 @@ int bootloader_env_set(const char *name, const char *value)
>>   		return -1;
>>   
>>   	if (fw_env_open (fw_env_opts)) {
>> -		ERROR("Error: environment not initialized\n");
>> +		ERROR("Error: environment not initialized, %s\n", strerror(errno));
>>   		unlock_uboot_env(lock);
>>   		return -1;
>>   	}
>> @@ -103,7 +103,7 @@ char *bootloader_env_get(const char *name)
>>   		return NULL;
>>   
>>   	if (fw_env_open (fw_env_opts)) {
>> -		ERROR("Error: environment not initialized\n");
>> +		ERROR("Error: environment not initialized, %s\n", strerror(errno));
>>   		unlock_uboot_env(lock);
>>   		return NULL;
>>   	}
>> @@ -126,7 +126,7 @@ int bootloader_apply_list(const char *filename)
>>   
>>   	lockfd = lock_uboot_env();
>>   	if (lockfd < 0) {
>> -		ERROR("Error opening U-Boot lock file %s\n", lockname);
>> +		ERROR("Error opening U-Boot lock file %s, %s\n", lockname, strerror(errno));
>>   		return -ENODEV;
>>   	}
>>   
> 
> Your and other patches are proofing that I economized with the error ouput..
> 
> Acked-by: Stefano Babic <sbabic@denx.de>
> 
> Best regards,
> Stefano Babic
> 
>
Stefano Babic Oct. 9, 2017, 10:38 a.m. UTC | #3
On 06/10/2017 11:45, Romain Bazile wrote:
> Makes the error easier to debug with the output of the error string
> 
> Signed-off-by: Romain Bazile <romain.bazile@ubiant.com>
> ---
>  bootloader/uboot.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/bootloader/uboot.c b/bootloader/uboot.c
> index 3b5a5ad..3697fe6 100644
> --- a/bootloader/uboot.c
> +++ b/bootloader/uboot.c
> @@ -47,11 +47,11 @@ static int lock_uboot_env(void)
>  	int lockfd = -1;
>  	lockfd = open(lockname, O_WRONLY | O_CREAT | O_TRUNC, 0666);
>  	if (lockfd < 0) {
> -		ERROR("Error opening U-Boot lock file %s\n", lockname);
> +		ERROR("Error opening U-Boot lock file %s, %s\n", lockname, strerror(errno));
>  		return -1;
>  	}
>  	if (flock(lockfd, LOCK_EX) < 0) {
> -		ERROR("Error locking file %s\n", lockname);
> +		ERROR("Error locking file %s, %s\n", lockname, strerror(errno));
>  		close(lockfd);
>  		return -1;
>  	}
> @@ -74,7 +74,7 @@ int bootloader_env_set(const char *name, const char *value)
>  		return -1;
>  
>  	if (fw_env_open (fw_env_opts)) {
> -		ERROR("Error: environment not initialized\n");
> +		ERROR("Error: environment not initialized, %s\n", strerror(errno));
>  		unlock_uboot_env(lock);
>  		return -1;
>  	}
> @@ -103,7 +103,7 @@ char *bootloader_env_get(const char *name)
>  		return NULL;
>  
>  	if (fw_env_open (fw_env_opts)) {
> -		ERROR("Error: environment not initialized\n");
> +		ERROR("Error: environment not initialized, %s\n", strerror(errno));
>  		unlock_uboot_env(lock);
>  		return NULL;
>  	}
> @@ -126,7 +126,7 @@ int bootloader_apply_list(const char *filename)
>  
>  	lockfd = lock_uboot_env();
>  	if (lockfd < 0) {
> -		ERROR("Error opening U-Boot lock file %s\n", lockname);
> +		ERROR("Error opening U-Boot lock file %s, %s\n", lockname, strerror(errno));
>  		return -ENODEV;
>  	}
>  
> 

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/bootloader/uboot.c b/bootloader/uboot.c
index 3b5a5ad..3697fe6 100644
--- a/bootloader/uboot.c
+++ b/bootloader/uboot.c
@@ -47,11 +47,11 @@  static int lock_uboot_env(void)
 	int lockfd = -1;
 	lockfd = open(lockname, O_WRONLY | O_CREAT | O_TRUNC, 0666);
 	if (lockfd < 0) {
-		ERROR("Error opening U-Boot lock file %s\n", lockname);
+		ERROR("Error opening U-Boot lock file %s, %s\n", lockname, strerror(errno));
 		return -1;
 	}
 	if (flock(lockfd, LOCK_EX) < 0) {
-		ERROR("Error locking file %s\n", lockname);
+		ERROR("Error locking file %s, %s\n", lockname, strerror(errno));
 		close(lockfd);
 		return -1;
 	}
@@ -74,7 +74,7 @@  int bootloader_env_set(const char *name, const char *value)
 		return -1;
 
 	if (fw_env_open (fw_env_opts)) {
-		ERROR("Error: environment not initialized\n");
+		ERROR("Error: environment not initialized, %s\n", strerror(errno));
 		unlock_uboot_env(lock);
 		return -1;
 	}
@@ -103,7 +103,7 @@  char *bootloader_env_get(const char *name)
 		return NULL;
 
 	if (fw_env_open (fw_env_opts)) {
-		ERROR("Error: environment not initialized\n");
+		ERROR("Error: environment not initialized, %s\n", strerror(errno));
 		unlock_uboot_env(lock);
 		return NULL;
 	}
@@ -126,7 +126,7 @@  int bootloader_apply_list(const char *filename)
 
 	lockfd = lock_uboot_env();
 	if (lockfd < 0) {
-		ERROR("Error opening U-Boot lock file %s\n", lockname);
+		ERROR("Error opening U-Boot lock file %s, %s\n", lockname, strerror(errno));
 		return -ENODEV;
 	}