[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 28/30] Improved symbolic error names
- To: Suren Baghdasaryan <surenb@xxxxxxxxxx>, akpm@xxxxxxxxxxxxxxxxxxxx
- From: Joe Perches <joe@xxxxxxxxxxx>
- Date: Thu, 01 Sep 2022 16:19:35 -0700
- Cc: kent.overstreet@xxxxxxxxx, mhocko@xxxxxxxx, vbabka@xxxxxxx, hannes@xxxxxxxxxxx, roman.gushchin@xxxxxxxxx, mgorman@xxxxxxx, dave@xxxxxxxxxxxx, willy@xxxxxxxxxxxxx, liam.howlett@xxxxxxxxxx, void@xxxxxxxxxxxxx, peterz@xxxxxxxxxxxxx, juri.lelli@xxxxxxxxxx, ldufour@xxxxxxxxxxxxx, peterx@xxxxxxxxxx, david@xxxxxxxxxx, axboe@xxxxxxxxx, mcgrof@xxxxxxxxxx, masahiroy@xxxxxxxxxx, nathan@xxxxxxxxxx, changbin.du@xxxxxxxxx, ytcoode@xxxxxxxxx, vincent.guittot@xxxxxxxxxx, dietmar.eggemann@xxxxxxx, rostedt@xxxxxxxxxxx, bsegall@xxxxxxxxxx, bristot@xxxxxxxxxx, vschneid@xxxxxxxxxx, cl@xxxxxxxxx, penberg@xxxxxxxxxx, iamjoonsoo.kim@xxxxxxx, 42.hyeyoo@xxxxxxxxx, glider@xxxxxxxxxx, elver@xxxxxxxxxx, dvyukov@xxxxxxxxxx, shakeelb@xxxxxxxxxx, songmuchun@xxxxxxxxxxxxx, arnd@xxxxxxxx, jbaron@xxxxxxxxxx, rientjes@xxxxxxxxxx, minchan@xxxxxxxxxx, kaleshsingh@xxxxxxxxxx, kernel-team@xxxxxxxxxxx, linux-mm@xxxxxxxxx, iommu@xxxxxxxxxxxxxxx, kasan-dev@xxxxxxxxxxxxxxxx, io-uring@xxxxxxxxxxxxxxx, linux-arch@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-bcache@xxxxxxxxxxxxxxx, linux-modules@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
- Delivery-date: Thu, 01 Sep 2022 23:20:12 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, 2022-08-30 at 14:49 -0700, Suren Baghdasaryan wrote:
> From: Kent Overstreet <kent.overstreet@xxxxxxxxx>
>
> This patch adds per-error-site error codes, with error strings that
> include their file and line number.
>
> To use, change code that returns an error, e.g.
> return -ENOMEM;
> to
> return -ERR(ENOMEM);
>
> Then, errname() will return a string that includes the file and line
> number of the ERR() call, for example
> printk("Got error %s!\n", errname(err));
> will result in
> Got error ENOMEM at foo.c:1234
Why? Something wrong with just using %pe ?
printk("Got error %pe at %s:%d!\n", ERR_PTR(err), __FILE__, __LINE__);
Likely __FILE__ and __LINE__ aren't particularly useful.
And using ERR would add rather a lot of bloat as each codetag_error_code
struct would be unique.
+#define ERR(_err) \
+({ \
+ static struct codetag_error_code \
+ __used \
+ __section("error_code_tags") \
+ __aligned(8) e = { \
+ .str = #_err " at " __FILE__ ":" __stringify(__LINE__),\
+ .err = _err, \
+ }; \
+ \
+ e.err; \
+})
|