diff mbox series

block: print symbolic error name instead of error code

Message ID 20240111231521.1596838-1-christian@heusel.eu (mailing list archive)
State New, archived
Headers show
Series block: print symbolic error name instead of error code | expand

Commit Message

Christian Heusel Jan. 11, 2024, 11:15 p.m. UTC
Utilize the %pe print specifier to get the symbolic error name as a
string (i.e "-ENOMEM") in the log message instead of the error code to
increase its readablility.

This change was suggested in
https://lore.kernel.org/all/92972476-0b1f-4d0a-9951-af3fc8bc6e65@suswa.mountain/

Signed-off-by: Christian Heusel <christian@heusel.eu>
---
 block/partitions/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Damien Le Moal Jan. 11, 2024, 11:37 p.m. UTC | #1
On 1/12/24 08:15, Christian Heusel wrote:
> Utilize the %pe print specifier to get the symbolic error name as a
> string (i.e "-ENOMEM") in the log message instead of the error code to
> increase its readablility.
> 
> This change was suggested in
> https://lore.kernel.org/all/92972476-0b1f-4d0a-9951-af3fc8bc6e65@suswa.mountain/
> 
> Signed-off-by: Christian Heusel <christian@heusel.eu>
> ---
>  block/partitions/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index f47ffcfdfcec..932df4db76f1 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -570,8 +570,8 @@ static bool blk_add_partition(struct gendisk *disk,
>  	part = add_partition(disk, p, from, size, state->parts[p].flags,
>  			     &state->parts[p].info);
>  	if (IS_ERR(part) && PTR_ERR(part) != -ENXIO) {
> -		printk(KERN_ERR " %s: p%d could not be added: %ld\n",
> -		       disk->disk_name, p, -PTR_ERR(part));
> +		printk(KERN_ERR " %s: p%d could not be added: %pe\n",
> +		       disk->disk_name, p, part);

pr_err() ?

>  		return true;
>  	}
>
Christian Heusel Jan. 11, 2024, 11:56 p.m. UTC | #2
On 24/01/12 08:37AM, Damien Le Moal wrote:
> On 1/12/24 08:15, Christian Heusel wrote:
> > -           printk(KERN_ERR " %s: p%d could not be added: %ld\n",
> > -                  disk->disk_name, p, -PTR_ERR(part));
> > +           printk(KERN_ERR " %s: p%d could not be added: %pe\n",
> > +                  disk->disk_name, p, part);
>
> pr_err() ?

If desired I can send a v2 containing another patch which refactors the
usages of printk into their respective pr_* aliases, but I wanted to
keep this consistent to the usages in rest of the file and do one change
at a time.

Cheers,
Chris
Jens Axboe Jan. 12, 2024, 12:12 a.m. UTC | #3
On 1/11/24 4:56 PM, Christian Heusel wrote:
> On 24/01/12 08:37AM, Damien Le Moal wrote:
>> On 1/12/24 08:15, Christian Heusel wrote:
>>> -           printk(KERN_ERR " %s: p%d could not be added: %ld\n",
>>> -                  disk->disk_name, p, -PTR_ERR(part));
>>> +           printk(KERN_ERR " %s: p%d could not be added: %pe\n",
>>> +                  disk->disk_name, p, part);
>>
>> pr_err() ?
> 
> If desired I can send a v2 containing another patch which refactors the
> usages of printk into their respective pr_* aliases, but I wanted to
> keep this consistent to the usages in rest of the file and do one change
> at a time.

Yes let's please keep that separate, not a huge fan of conversions of that
anyway as it just causes backports or stable kernel issues.
Chaitanya Kulkarni Jan. 12, 2024, 4:34 a.m. UTC | #4
On 1/11/24 15:15, Christian Heusel wrote:
> Utilize the %pe print specifier to get the symbolic error name as a
> string (i.e "-ENOMEM") in the log message instead of the error code to
> increase its readablility.
>
> This change was suggested in
> https://lore.kernel.org/all/92972476-0b1f-4d0a-9951-af3fc8bc6e65@suswa.mountain/
>
> Signed-off-by: Christian Heusel <christian@heusel.eu>
> ---
>

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
Jens Axboe Jan. 12, 2024, 4:08 p.m. UTC | #5
On Fri, 12 Jan 2024 00:15:18 +0100, Christian Heusel wrote:
> Utilize the %pe print specifier to get the symbolic error name as a
> string (i.e "-ENOMEM") in the log message instead of the error code to
> increase its readablility.
> 
> This change was suggested in
> https://lore.kernel.org/all/92972476-0b1f-4d0a-9951-af3fc8bc6e65@suswa.mountain/
> 
> [...]

Applied, thanks!

[1/1] block: print symbolic error name instead of error code
      commit: 25c1772a0493463408489b1fae65cf77fe46cac1

Best regards,
diff mbox series

Patch

diff --git a/block/partitions/core.c b/block/partitions/core.c
index f47ffcfdfcec..932df4db76f1 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -570,8 +570,8 @@  static bool blk_add_partition(struct gendisk *disk,
 	part = add_partition(disk, p, from, size, state->parts[p].flags,
 			     &state->parts[p].info);
 	if (IS_ERR(part) && PTR_ERR(part) != -ENXIO) {
-		printk(KERN_ERR " %s: p%d could not be added: %ld\n",
-		       disk->disk_name, p, -PTR_ERR(part));
+		printk(KERN_ERR " %s: p%d could not be added: %pe\n",
+		       disk->disk_name, p, part);
 		return true;
 	}