From: Jani Nikula <jani.nikula@linux.intel.com>
To: Matthew Brost <matthew.brost@intel.com>,
intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: maarten.lankhorst@linux.intel.com, rodrigo.vivi@intel.com
Subject: Re: [PATCH v4 2/3] drm/printer: Allow NULL data in devcoredump printer
Date: Thu, 01 Aug 2024 11:05:21 +0300 [thread overview]
Message-ID: <87le1gwtvi.fsf@intel.com> (raw)
In-Reply-To: <20240731213221.2523989-3-matthew.brost@intel.com>
On Wed, 31 Jul 2024, Matthew Brost <matthew.brost@intel.com> wrote:
> Useful to determine size of devcoreump before writing it out.
I find it useful to have this special case documented, with an example,
so it's easier to see how handy this really is.
BR,
Jani.
>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/drm_print.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
> index cf24dfdeb6b2..a1a4de9f9c44 100644
> --- a/drivers/gpu/drm/drm_print.c
> +++ b/drivers/gpu/drm/drm_print.c
> @@ -100,8 +100,9 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str)
> copy = iterator->remain;
>
> /* Copy out the bit of the string that we need */
> - memcpy(iterator->data,
> - str + (iterator->start - iterator->offset), copy);
> + if (iterator->data)
> + memcpy(iterator->data,
> + str + (iterator->start - iterator->offset), copy);
>
> iterator->offset = iterator->start + copy;
> iterator->remain -= copy;
> @@ -110,7 +111,8 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str)
>
> len = min_t(ssize_t, strlen(str), iterator->remain);
>
> - memcpy(iterator->data + pos, str, len);
> + if (iterator->data)
> + memcpy(iterator->data + pos, str, len);
>
> iterator->offset += len;
> iterator->remain -= len;
> @@ -140,8 +142,9 @@ void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf)
> if ((iterator->offset >= iterator->start) && (len < iterator->remain)) {
> ssize_t pos = iterator->offset - iterator->start;
>
> - snprintf(((char *) iterator->data) + pos,
> - iterator->remain, "%pV", vaf);
> + if (iterator->data)
> + snprintf(((char *) iterator->data) + pos,
> + iterator->remain, "%pV", vaf);
>
> iterator->offset += len;
> iterator->remain -= len;
--
Jani Nikula, Intel
next prev parent reply other threads:[~2024-08-01 8:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-31 21:32 [PATCH v4 0/3] Faster devcoredump and fixes Matthew Brost
2024-07-31 21:32 ` [PATCH v4 1/3] drm/xe: Take ref to VM in delayed snapshot Matthew Brost
2024-07-31 22:24 ` Cavitt, Jonathan
2024-07-31 21:32 ` [PATCH v4 2/3] drm/printer: Allow NULL data in devcoredump printer Matthew Brost
2024-07-31 22:22 ` Cavitt, Jonathan
2024-08-01 0:02 ` Matthew Brost
2024-08-01 14:00 ` Cavitt, Jonathan
2024-08-01 14:29 ` Matthew Brost
2024-08-01 14:38 ` Cavitt, Jonathan
2024-08-01 8:05 ` Jani Nikula [this message]
2024-08-01 14:27 ` Matthew Brost
2024-07-31 21:32 ` [PATCH v4 3/3] drm/xe: Faster devcoredump Matthew Brost
2024-07-31 22:31 ` Cavitt, Jonathan
2024-08-01 0:00 ` Matthew Brost
2024-07-31 21:36 ` ✓ CI.Patch_applied: success for Faster devcoredump and fixes Patchwork
2024-07-31 21:37 ` ✗ CI.checkpatch: warning " Patchwork
2024-07-31 21:38 ` ✓ CI.KUnit: success " Patchwork
2024-07-31 21:50 ` ✓ CI.Build: " Patchwork
2024-07-31 21:52 ` ✓ CI.Hooks: " Patchwork
2024-07-31 21:53 ` ✗ CI.checksparse: warning " Patchwork
2024-07-31 22:25 ` ✓ CI.BAT: success " Patchwork
2024-08-01 2:21 ` ✗ CI.FULL: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87le1gwtvi.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).