lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <16b08ba3-0d38-eb0f-8d4d-1da55ef38852@siddh.me>
Date:   Wed, 21 Dec 2022 21:08:01 +0530
From:   Siddh Raman Pant <code@...dh.me>
To:     Thomas Zimmermann <tzimmermann@...e.de>
Cc:     dri-devel <dri-devel@...ts.freedesktop.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Maxime Ripard <mripard@...nel.org>,
        David Airlie <airlied@...il.com>,
        Daniel Vetter <daniel@...ll.ch>
Subject: Re: [PATCH 04/10] drm/print: Fix support for NULL as first argument
 of drm_dbg_*

On Wed, Dec 21 2022 at 14:38:08 +0530, Thomas Zimmermann wrote:
> Hi
> 
> Am 20.12.22 um 21:16 schrieb Siddh Raman Pant:
>> Comments say macros DRM_DEBUG_* are deprecated in favor of
>> drm_dbg_*(NULL, ...), but they have broken support for it,
>> as the macro will result in `(NULL) ? (NULL)->dev : NULL`.
>>
>> Thus, fix them by casting input drm to a temporary struct ptr,
>> with the same convention as in __DRM_DEFINE_DBG_RATELIMITED.
>>
>> Signed-off-by: Siddh Raman Pant <code@...dh.me>
>> ---
>>   include/drm/drm_print.h | 89 ++++++++++++++++++++++++++++++++---------
>>   1 file changed, 69 insertions(+), 20 deletions(-)
>>
>> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
>> index a44fb7ef257f..53702d830291 100644
>> --- a/include/drm/drm_print.h
>> +++ b/include/drm/drm_print.h
>> @@ -486,26 +486,75 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev,
>>       __drm_printk((drm), err, _ratelimited, "*ERROR* " fmt, ##__VA_ARGS__)
>>     -#define drm_dbg_core(drm, fmt, ...)                    \
>> -    drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__)
> ...
>> +#define drm_dbg_core(drm, fmt, ...)                \
>> +({                                \
>> +    const struct drm_device *drm_ = (drm);            \
>> +    drm_dev_dbg(drm_ ? drm_->dev : NULL, DRM_UT_CORE,    \
>> +            fmt, ##__VA_ARGS__);            \
>> +})
> 
> Instead of doing this for each drm_dbg_ macro, rather add an internal helper that returns the device or NULL like this:
> 
> static inline struct device *__drm_print_dev(struct drm_device *drm)
> {
>     if (drm)
>         return drm->dev;
>     return NULL;
> }
> 
> and change the macros to
> 
> drm_dbg_core(drm, fmt, ...)
>     drm_dev_dbg(__drm_print_dev(drm), DRM_UT_CORE, )
> 
> and so on.
> 
> Best regards
> Thomas

Sure, I'll send a v2.

Thanks,
Siddh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ