Message ID | 1329727489-31423-1-git-send-email-walle@corscience.de |
---|---|
State | Changes Requested |
Delegated to: | Stefan Roese |
Headers | show |
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 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; > } > 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,
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; }
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(-)