From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Modem, Bhanuprakash" <bhanuprakash.modem@intel.com>
Cc: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Subject: Re: [igt-dev] [PATCH i-g-t 1/7] lib: Introduce igt_memdup()
Date: Mon, 18 Oct 2021 10:19:41 +0300 [thread overview]
Message-ID: <YW0gDYSzbuHlnQ5+@intel.com> (raw)
In-Reply-To: <DM8PR11MB571916D91BEA231F737525A28DBC9@DM8PR11MB5719.namprd11.prod.outlook.com>
On Mon, Oct 18, 2021 at 04:19:41AM +0000, Modem, Bhanuprakash wrote:
> > From: igt-dev <igt-dev-bounces@lists.freedesktop.org> On Behalf Of Ville
> > Syrjala
> > Sent: Wednesday, October 13, 2021 6:30 PM
> > To: igt-dev@lists.freedesktop.org
> > Subject: [igt-dev] [PATCH i-g-t 1/7] lib: Introduce igt_memdup()
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Provide a helper to do the malloc()+memcpy() in one swift blow.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> > lib/igt_aux.c | 11 +++++++++++
> > lib/igt_aux.h | 2 ++
> > 2 files changed, 13 insertions(+)
> >
> > diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> > index 1217f5e88094..2445e483e210 100644
> > --- a/lib/igt_aux.c
> > +++ b/lib/igt_aux.c
> > @@ -1527,3 +1527,14 @@ uint64_t vfs_file_max(void)
> > }
> > return max;
> > }
> > +
> > +void *igt_memdup(const void *ptr, size_t len)
> > +{
> > + void *dup;
> > +
> > + dup = malloc(len);
> > + if (dup)
> > + memcpy(dup, ptr, len);
> > +
> > + return dup;
>
> Don't we need to handle the malloc() failures?
Returning NULL is the way we handle malloc failures.
> If it is fine to return NULL (in case of malloc failure) from here,
> I haven't seen that any caller (Other patches in this series) is handling
> this NULL.
In actual tests the normal way to handle malloc failures is by
exploding. Nothing special needed for that.
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2021-10-18 7:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 12:59 [igt-dev] [PATCH i-g-t 0/7] kms: Fix i915 fixed_mode vrefresh fallout Ville Syrjala
2021-10-13 12:59 ` [igt-dev] [PATCH i-g-t 1/7] lib: Introduce igt_memdup() Ville Syrjala
2021-10-18 4:19 ` Modem, Bhanuprakash
2021-10-18 7:19 ` Ville Syrjälä [this message]
2021-10-18 10:10 ` Modem, Bhanuprakash
2021-10-13 12:59 ` [igt-dev] [PATCH i-g-t 2/7] tests/i915/kms_frontbuffer_tracking: Get rid of the funny mode_copy Ville Syrjala
2021-10-18 4:34 ` Modem, Bhanuprakash
2021-10-13 12:59 ` [igt-dev] [PATCH i-g-t 3/7] lib/kms: Have igt_std_1024_mode_get() return a copy of the mode Ville Syrjala
2021-10-18 4:56 ` Modem, Bhanuprakash
2021-10-13 12:59 ` [igt-dev] [PATCH i-g-t 4/7] lib/kms: Have igt_std_1024_mode_get() return a mode with specific refresh Ville Syrjala
2021-10-18 4:59 ` Modem, Bhanuprakash
2021-10-13 12:59 ` [igt-dev] [PATCH i-g-t 5/7] lib/kms: Introduce igt_output_preferred_vrefresh() Ville Syrjala
2021-10-18 5:00 ` Modem, Bhanuprakash
2021-10-13 12:59 ` [igt-dev] [PATCH i-g-t 6/7] tests/i915/kms_frontbuffer_tracking: Use preferred modes's vrefresh Ville Syrjala
2021-10-18 5:02 ` Modem, Bhanuprakash
2021-10-13 12:59 ` [igt-dev] [PATCH i-g-t 7/7] tests/kms_concurrent: " Ville Syrjala
2021-10-18 5:03 ` Modem, Bhanuprakash
2021-10-13 15:16 ` [igt-dev] ✗ Fi.CI.BAT: failure for kms: Fix i915 fixed_mode vrefresh fallout Patchwork
2021-10-14 8:35 ` [igt-dev] ✓ Fi.CI.BAT: success for kms: Fix i915 fixed_mode vrefresh fallout (rev2) Patchwork
2021-10-14 9:34 ` [igt-dev] ✗ Fi.CI.IGT: 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=YW0gDYSzbuHlnQ5+@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=bhanuprakash.modem@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/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