From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: kyungmin.park@samsung.com, yj44.cho@samsung.com,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 2/3] drm: add assertion for checking null edid to drm_edid_block_valid
Date: Tue, 2 Jul 2013 11:29:23 +0300 [thread overview]
Message-ID: <20130702082923.GJ5004@intel.com> (raw)
In-Reply-To: <1372726322-29261-1-git-send-email-sw0312.kim@samsung.com>
On Tue, Jul 02, 2013 at 09:52:02AM +0900, Seung-Woo Kim wrote:
> If raw_edid of drm_edid_block_vaild() is null, it will crash, so
> checking in bad label is removed and instead assertion is added at
> the top of the function.
> The type of return for the function is bool, so it fixes to return
> true and false instead of 1 and 0.
>
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> chages from v1
> - NULL checking is replaced with WARN_ON() as Daniel commented
> - all return value is replaced as true/false as Chris and Daniel commented
>
> drivers/gpu/drm/drm_edid.c | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 2dc1a60..1117f02 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -968,6 +968,8 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid)
> u8 csum = 0;
> struct edid *edid = (struct edid *)raw_edid;
>
> + WARN_ON(!raw_edid);
> +
I don't see this buying us anything. All you get is two backtraces
instead of one.
if (WARN_ON(!raw_edid))
return false;
would make more sense if we want tolerate programmer errors a bit
better. I'm not a huge fan of such defensive programming though
since it tends to make it less clear what the function actually
expects from you. But here the WARN_ON() would at least make it
clear that it's not meant to happen.
> if (edid_fixup > 8 || edid_fixup < 0)
> edid_fixup = 6;
>
> @@ -1010,15 +1012,15 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid)
> break;
> }
>
> - return 1;
> + return true;
>
> bad:
> - if (raw_edid && print_bad_edid) {
> + if (print_bad_edid) {
> printk(KERN_ERR "Raw EDID:\n");
> print_hex_dump(KERN_ERR, " \t", DUMP_PREFIX_NONE, 16, 1,
> raw_edid, EDID_LENGTH, false);
> }
> - return 0;
> + return false;
> }
> EXPORT_SYMBOL(drm_edid_block_valid);
>
> --
> 1.7.4.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Ville Syrjälä
Intel OTC
next prev parent reply other threads:[~2013-07-02 8:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-01 10:06 [PATCH 0/3] drm: minor cleanups Seung-Woo Kim
2013-07-01 10:06 ` [PATCH 1/3] drm: fix print format of sequence in trace point Seung-Woo Kim
2013-07-01 10:23 ` Chris Wilson
2013-07-01 10:28 ` Seung-Woo Kim
2013-07-01 10:34 ` Chris Wilson
2013-07-01 10:44 ` [PATCH v2 " Seung-Woo Kim
2013-07-01 10:49 ` Chris Wilson
2013-07-01 10:06 ` [PATCH 2/3] drm: move edid null check to the first part of drm_edid_block_valid Seung-Woo Kim
2013-07-01 10:21 ` Chris Wilson
2013-07-01 14:56 ` Daniel Vetter
2013-07-01 23:54 ` Seung-Woo Kim
2013-07-02 0:11 ` [PATCH v3 3/3] drm: fix error routines in drm_open_helper Seung-Woo Kim
2013-07-02 0:52 ` [PATCH v2 2/3] drm: add assertion for checking null edid to drm_edid_block_valid Seung-Woo Kim
2013-07-02 8:29 ` Ville Syrjälä [this message]
2013-07-02 8:47 ` Seung-Woo Kim
2013-07-02 8:57 ` [PATCH v3 " Seung-Woo Kim
2013-07-02 11:22 ` Chris Wilson
2013-07-02 11:20 ` [PATCH v2 " Chris Wilson
2013-07-01 10:06 ` [PATCH 3/3] drm: fix error routines in drm_open_helper Seung-Woo Kim
2013-07-01 10:18 ` Chris Wilson
2013-07-01 10:49 ` [PATCH v2 " Seung-Woo Kim
2013-07-01 10:57 ` Chris Wilson
2013-07-01 11:14 ` Seung-Woo Kim
2013-07-01 11:52 ` Chris Wilson
2013-07-01 12:02 ` YoungJun Cho
2013-07-02 0:53 ` [PATCH v4 " Seung-Woo Kim
2013-07-02 11:19 ` Chris Wilson
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=20130702082923.GJ5004@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kyungmin.park@samsung.com \
--cc=sw0312.kim@samsung.com \
--cc=yj44.cho@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.