Re: [PATCH:xkbcomp 1/4] Remove useless checks for NULL before free in OverlayKeyCreate()
Hi, On 11 March 2014 06:31, Peter Hutterer peter.hutte...@who-t.net wrote: On Sat, Mar 08, 2014 at 07:10:25PM -0800, Alan Coopersmith wrote: There is no need to ensure the pointers passed to free are not NULL, especially right after passing them to strncpy without checking for NULL. Flagged by cppcheck 1.64: [app/xkbcomp/parseutils.c:557] - [app/xkbcomp/parseutils.c:559]: (warning) Possible null pointer dereference: over - otherwise it is redundant to check it against null. [app/xkbcomp/parseutils.c:558] - [app/xkbcomp/parseutils.c:561]: (warning) Possible null pointer dereference: under - otherwise it is redundant to check it against null. Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com series: Reviewed-by: Peter Hutterer peter.hutte...@who-t.net Ditto from me. Cheers, Daniel ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH:xkbcomp 1/4] Remove useless checks for NULL before free in OverlayKeyCreate()
On Sat, Mar 08, 2014 at 07:10:25PM -0800, Alan Coopersmith wrote: There is no need to ensure the pointers passed to free are not NULL, especially right after passing them to strncpy without checking for NULL. Flagged by cppcheck 1.64: [app/xkbcomp/parseutils.c:557] - [app/xkbcomp/parseutils.c:559]: (warning) Possible null pointer dereference: over - otherwise it is redundant to check it against null. [app/xkbcomp/parseutils.c:558] - [app/xkbcomp/parseutils.c:561]: (warning) Possible null pointer dereference: under - otherwise it is redundant to check it against null. Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com series: Reviewed-by: Peter Hutterer peter.hutte...@who-t.net Cheers, Peter --- parseutils.c |6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/parseutils.c b/parseutils.c index a1b6e9e..c08353d 100644 --- a/parseutils.c +++ b/parseutils.c @@ -556,10 +556,8 @@ OverlayKeyCreate(char *under, char *over) key-common.stmtType = StmtOverlayKeyDef; strncpy(key-over, over, XkbKeyNameLength); strncpy(key-under, under, XkbKeyNameLength); -if (over) -uFree(over); -if (under) -uFree(under); +uFree(over); +uFree(under); } return key; } -- 1.7.9.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH:xkbcomp 1/4] Remove useless checks for NULL before free in OverlayKeyCreate()
There is no need to ensure the pointers passed to free are not NULL, especially right after passing them to strncpy without checking for NULL. Flagged by cppcheck 1.64: [app/xkbcomp/parseutils.c:557] - [app/xkbcomp/parseutils.c:559]: (warning) Possible null pointer dereference: over - otherwise it is redundant to check it against null. [app/xkbcomp/parseutils.c:558] - [app/xkbcomp/parseutils.c:561]: (warning) Possible null pointer dereference: under - otherwise it is redundant to check it against null. Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com --- parseutils.c |6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/parseutils.c b/parseutils.c index a1b6e9e..c08353d 100644 --- a/parseutils.c +++ b/parseutils.c @@ -556,10 +556,8 @@ OverlayKeyCreate(char *under, char *over) key-common.stmtType = StmtOverlayKeyDef; strncpy(key-over, over, XkbKeyNameLength); strncpy(key-under, under, XkbKeyNameLength); -if (over) -uFree(over); -if (under) -uFree(under); +uFree(over); +uFree(under); } return key; } -- 1.7.9.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel