[U-Boot] [PATCH] UBIFS: Improve error message when reading superblock failed

In addition to the error message also display the error code. I had the problem that my malloc memory was not enough (ENOMEM), and if u-boot had displayed the error code immediately that would have saved me some debugging.
Signed-off-by: Bernhard Walle walle@corscience.de --- fs/ubifs/super.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 26b48f0..0b1440b 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1191,7 +1191,7 @@ int ubifs_mount(char *vol_name) mnt = NULL; ret = ubifs_get_sb(&ubifs_fs_type, flags, name, data, mnt); if (ret) { - printf("Error reading superblock on volume '%s'!\n", name); + printf("Error reading superblock on volume '%s': %d!\n", name, -ret); return -1; }

Hi Bernhard,
In addition to the error message also display the error code. I had the problem that my malloc memory was not enough (ENOMEM), and if u-boot had displayed the error code immediately that would have saved me some debugging.
Signed-off-by: Bernhard Walle walle@corscience.de
fs/ubifs/super.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 26b48f0..0b1440b 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1191,7 +1191,7 @@ int ubifs_mount(char *vol_name) mnt = NULL; ret = ubifs_get_sb(&ubifs_fs_type, flags, name, data, mnt); if (ret) {
printf("Error reading superblock on volume '%s'!\n", name);
return -1; }printf("Error reading superblock on volume '%s': %d!\n", name, -ret);
I think this makes sense, but I think it would be more natural to print the real error code, not the negative value. I don't know how to search for all such occurrences, but I cannot find any but a lot of sites printing the error code as is.
Cheers Detlev

Hi Detlev,
* Detlev Zundel dzu@denx.de [2012-02-17 15:15]:
@@ -1191,7 +1191,7 @@ int ubifs_mount(char *vol_name) mnt = NULL; ret = ubifs_get_sb(&ubifs_fs_type, flags, name, data, mnt); if (ret) {
printf("Error reading superblock on volume '%s'!\n", name);
return -1; }printf("Error reading superblock on volume '%s': %d!\n", name, -ret);
I think this makes sense, but I think it would be more natural to print the real error code, not the negative value. I don't know how to search for all such occurrences, but I cannot find any but a lot of sites printing the error code as is.
well, the return value is negative, so my intention was to print the error code as positive number. So you think we should display it as negative number (-12 instead of 12 for ENOMEM)?
Regards, Bernhard

Hi Bernhard,
Hi Detlev,
- Detlev Zundel dzu@denx.de [2012-02-17 15:15]:
@@ -1191,7 +1191,7 @@ int ubifs_mount(char *vol_name) mnt = NULL; ret = ubifs_get_sb(&ubifs_fs_type, flags, name, data, mnt); if (ret) {
printf("Error reading superblock on volume '%s'!\n", name);
return -1; }printf("Error reading superblock on volume '%s': %d!\n", name, -ret);
I think this makes sense, but I think it would be more natural to print the real error code, not the negative value. I don't know how to search for all such occurrences, but I cannot find any but a lot of sites printing the error code as is.
well, the return value is negative, so my intention was to print the error code as positive number. So you think we should display it as negative number (-12 instead of 12 for ENOMEM)?
Personally I believe that any transformation in the printing can mislead people in the search for the cause or the responsible code.
So if the error value is -12, then we should print it. After all, the assignment to generate that value will very likely be "return -ENOMEM" and people will thus know what to look for.
On the other hand I am open to the consistency argument, so if every error printing would do such a transformation then it would be better to also do it. But as I said, I don't know an easy grep pattern to search for such locations and quick searches showed that I all places I found print the error codes unmangeld.
Cheers Detlev

In addition to the error message also display the error code. I had the problem that my malloc memory was not enough (ENOMEM), and if u-boot had displayed the error code immediately that would have saved me some debugging.
Signed-off-by: Bernhard Walle walle@corscience.de --- v2: Print the non-negated error value.
fs/ubifs/super.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 26b48f0..e6c02f5 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1191,7 +1191,7 @@ int ubifs_mount(char *vol_name) mnt = NULL; ret = ubifs_get_sb(&ubifs_fs_type, flags, name, data, mnt); if (ret) { - printf("Error reading superblock on volume '%s'!\n", name); + printf("Error reading superblock on volume '%s': %d!\n", name, ret); return -1; }

Hi Bernard,
Le 20/02/2012 09:44, Bernhard Walle a écrit :
In addition to the error message also display the error code. I had the problem that my malloc memory was not enough (ENOMEM), and if u-boot had displayed the error code immediately that would have saved me some debugging.
Signed-off-by: Bernhard Wallewalle@corscience.de
v2: Print the non-negated error value.
fs/ubifs/super.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 26b48f0..e6c02f5 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1191,7 +1191,7 @@ int ubifs_mount(char *vol_name) mnt = NULL; ret = ubifs_get_sb(&ubifs_fs_type, flags, name, data, mnt); if (ret) {
printf("Error reading superblock on volume '%s'!\n", name);
return -1; }printf("Error reading superblock on volume '%s': %d!\n", name, ret);
Dry numbers as error messages are better than no error messages but only marginally IMO. Isn't there a way to emit a readable message re malloc instead of emitting an int value?
Amicalement,

Am 20.02.2012 09:59, schrieb Albert ARIBAUD:
Dry numbers as error messages are better than no error messages but only marginally IMO. Isn't there a way to emit a readable message re malloc instead of emitting an int value?
Well, I'm not familiar with the u-boot codebase. Does u-boot have a strerror table? How is it handled on other places? Should an error message printed directly before returning -ENOMEM?
Regards, Bernhard

Hi Bernhard,
Le 20/02/2012 10:11, Bernhard Walle a écrit :
Am 20.02.2012 09:59, schrieb Albert ARIBAUD:
Dry numbers as error messages are better than no error messages but only marginally IMO. Isn't there a way to emit a readable message re malloc instead of emitting an int value?
Well, I'm not familiar with the u-boot codebase. Does u-boot have a strerror table? How is it handled on other places? Should an error message printed directly before returning -ENOMEM?
I don't think there is an strerror() API. But at least, if the newly printed int uses errno values, then instead of '... %d!", you could print "... errno=%d", which would give some hint to the reader.
Regards, Bernhard
Amicalement,

From: Bernhard Walle walle@corscience.de
In addition to the error message also display the error code. I had the problem that my malloc memory was not enough (ENOMEM), and if u-boot had displayed the error code immediately that would have saved me some debugging.
Signed-off-by: Bernhard Walle walle@corscience.de
Use ubifs_err instead of printf. Add "errno=%d" in output as suggested by Albert Aribaud. Signed-off-by: Thomas Weber weber@corscience.de --- fs/ubifs/super.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 26b48f0..30ccd98 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1191,7 +1191,7 @@ int ubifs_mount(char *vol_name) mnt = NULL; ret = ubifs_get_sb(&ubifs_fs_type, flags, name, data, mnt); if (ret) { - printf("Error reading superblock on volume '%s'!\n", name); + ubifs_err("Error reading superblock on volume '%s' errno=%d!\n", name, ret); return -1; }

Ccing Albert
Thomas
On 04/02/2012 01:58 PM, Thomas Weber wrote:
From: Bernhard Walle walle@corscience.de
In addition to the error message also display the error code. I had the problem that my malloc memory was not enough (ENOMEM), and if u-boot had displayed the error code immediately that would have saved me some debugging.
Signed-off-by: Bernhard Walle walle@corscience.de
Use ubifs_err instead of printf. Add "errno=%d" in output as suggested by Albert Aribaud. Signed-off-by: Thomas Weber weber@corscience.de
fs/ubifs/super.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 26b48f0..30ccd98 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1191,7 +1191,7 @@ int ubifs_mount(char *vol_name) mnt = NULL; ret = ubifs_get_sb(&ubifs_fs_type, flags, name, data, mnt); if (ret) {
printf("Error reading superblock on volume '%s'!\n", name);
return -1; }ubifs_err("Error reading superblock on volume '%s' errno=%d!\n", name, ret);

Dear Thomas Weber,
In message 1333367914-20461-1-git-send-email-weber@corscience.de you wrote:
From: Bernhard Walle walle@corscience.de
In addition to the error message also display the error code. I had the problem that my malloc memory was not enough (ENOMEM), and if u-boot had displayed the error code immediately that would have saved me some debugging.
Signed-off-by: Bernhard Walle walle@corscience.de
Use ubifs_err instead of printf. Add "errno=%d" in output as suggested by Albert Aribaud. Signed-off-by: Thomas Weber weber@corscience.de
fs/ubifs/super.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Applied, thanks.
Stefan, I hope this is OK with you.
Best regards,
Wolfgang Denk
participants (6)
-
Albert ARIBAUD
-
Bernhard Walle
-
Detlev Zundel
-
Thomas Weber
-
Thomas Weber
-
Wolfgang Denk