<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/scripts/coccinelle, branch next</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<entry>
<title>scripts: ensure the cocci script for miiphy_register does not leak the MDIO bus</title>
<updated>2021-09-28T15:50:57+00:00</updated>
<author>
<name>Vladimir Oltean</name>
<email>vladimir.oltean@nxp.com</email>
</author>
<published>2021-09-27T11:22:05+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=4df9f5e39fb224a4857c3411b4cbe419e4d339e8'/>
<id>4df9f5e39fb224a4857c3411b4cbe419e4d339e8</id>
<content type='text'>
When mdio_register fails, mdio_free should be called on the mdiodev that
was previously allocated with mdio_alloc.

Signed-off-by: Vladimir Oltean &lt;vladimir.oltean@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When mdio_register fails, mdio_free should be called on the mdiodev that
was previously allocated with mdio_alloc.

Signed-off-by: Vladimir Oltean &lt;vladimir.oltean@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: ensure the cocci script for miiphy_register does not leave NULL-unterminated strings</title>
<updated>2021-09-28T15:50:57+00:00</updated>
<author>
<name>Vladimir Oltean</name>
<email>vladimir.oltean@nxp.com</email>
</author>
<published>2021-09-27T11:22:01+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=81386ed40590bf746849ce1a1d3a2edd869bad84'/>
<id>81386ed40590bf746849ce1a1d3a2edd869bad84</id>
<content type='text'>
strncpy() simply bails out when copying a source string whose size
exceeds the destination string size, potentially leaving the destination
string unterminated.

One possible way to address is to pass MDIO_NAME_LEN - 1 and a
previously zero-initialized destination string, but this is more
difficult to maintain.

The chosen alternative is to use strlcpy(), which properly limits the
copy len in the (srclen &gt;= size) case to "size - 1", and which is also
more efficient than the strncpy() byte-by-byte implementation by using
memcpy. The destination string returned by strlcpy() is always NULL
terminated.

Signed-off-by: Vladimir Oltean &lt;vladimir.oltean@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
strncpy() simply bails out when copying a source string whose size
exceeds the destination string size, potentially leaving the destination
string unterminated.

One possible way to address is to pass MDIO_NAME_LEN - 1 and a
previously zero-initialized destination string, but this is more
difficult to maintain.

The chosen alternative is to use strlcpy(), which properly limits the
copy len in the (srclen &gt;= size) case to "size - 1", and which is also
more efficient than the strncpy() byte-by-byte implementation by using
memcpy. The destination string returned by strlcpy() is always NULL
terminated.

Signed-off-by: Vladimir Oltean &lt;vladimir.oltean@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>coccinelle: adjust NULL check before free()</title>
<updated>2020-04-24T20:40:09+00:00</updated>
<author>
<name>Heinrich Schuchardt</name>
<email>xypron.glpk@gmx.de</email>
</author>
<published>2020-04-19T09:56:02+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=c11f0d88ba462976335a4990a30a99d1d0b49195'/>
<id>c11f0d88ba462976335a4990a30a99d1d0b49195</id>
<content type='text'>
The free() function checks if its argument is NULL. We should avoid
checking for NULL before calling free like in

    if (result-&gt;tds)
        free(result-&gt;tds);

The list of relevant functions differs between Linux and U-Boot, e.g. we
use free().

Adjust the list of relevant functions.

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The free() function checks if its argument is NULL. We should avoid
checking for NULL before calling free like in

    if (result-&gt;tds)
        free(result-&gt;tds);

The list of relevant functions differs between Linux and U-Boot, e.g. we
use free().

Adjust the list of relevant functions.

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>coccinelle: check for casting malloc output</title>
<updated>2020-04-24T20:40:09+00:00</updated>
<author>
<name>Heinrich Schuchardt</name>
<email>xypron.glpk@gmx.de</email>
</author>
<published>2020-04-19T09:07:34+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=cb2a2ebd4f93220936de721918ed9a3ca57cc5db'/>
<id>cb2a2ebd4f93220936de721918ed9a3ca57cc5db</id>
<content type='text'>
Casting the (void *) output of memory allocation functions before
assignment like in

	sata-&gt;cmd_hdr_tbl_offset = (void *)malloc(length + align);

is useless.

Adopt the Linux kernel script
scripts/coccinelle/api/alloc/alloc_cast.cocci.

Now 'make coccicheck' generates warnings like:

./drivers/ata/fsl_sata.c:143:29-33:
WARNING: casting value returned by memory allocation function
to (void *) is useless.

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Casting the (void *) output of memory allocation functions before
assignment like in

	sata-&gt;cmd_hdr_tbl_offset = (void *)malloc(length + align);

is useless.

Adopt the Linux kernel script
scripts/coccinelle/api/alloc/alloc_cast.cocci.

Now 'make coccicheck' generates warnings like:

./drivers/ata/fsl_sata.c:143:29-33:
WARNING: casting value returned by memory allocation function
to (void *) is useless.

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts/coccinelle: add some more coccinelle tests</title>
<updated>2018-03-09T17:31:07+00:00</updated>
<author>
<name>Heinrich Schuchardt</name>
<email>xypron.glpk@gmx.de</email>
</author>
<published>2018-03-08T19:56:17+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=4320e2fda40ae5057777d4700192a0c55287b66a'/>
<id>4320e2fda40ae5057777d4700192a0c55287b66a</id>
<content type='text'>
kmerr: verify that malloc and calloc are followed by a check to verify
that we are not out of memory.

badzero: Compare pointer-typed values to NULL rather than 0

Both checks are copied from the Linux kernel archive.

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
kmerr: verify that malloc and calloc are followed by a check to verify
that we are not out of memory.

badzero: Compare pointer-typed values to NULL rather than 0

Both checks are copied from the Linux kernel archive.

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts/coccinelle: add some more coccinelle tests</title>
<updated>2017-11-21T01:18:39+00:00</updated>
<author>
<name>Heinrich Schuchardt</name>
<email>xypron.glpk@gmx.de</email>
</author>
<published>2017-11-10T18:15:02+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=06feb5d0bf9953c6918d0e35feef64521c5236c4'/>
<id>06feb5d0bf9953c6918d0e35feef64521c5236c4</id>
<content type='text'>
Add some useful static code analysis scripts for coccinelle
copied from the Linux kernel v4.14-rc8:

Warn on check against NULL before calling free.
scripts/coccinelle/free/ifnullfree.cocci

Detect superfluous NULL check for list iterator.
scripts/coccinelle/iterators/itnull.cocci

Check if list iterator is reassigned.
scripts/coccinelle/iterators/list_entry_update.cocci

Check if list iterator is used after loop.
scripts/coccinelle/iterators/use_after_iter.cocci

Find wrong argument of sizeof in allocation function:
scripts/coccinelle/misc/badty.cocci

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add some useful static code analysis scripts for coccinelle
copied from the Linux kernel v4.14-rc8:

Warn on check against NULL before calling free.
scripts/coccinelle/free/ifnullfree.cocci

Detect superfluous NULL check for list iterator.
scripts/coccinelle/iterators/itnull.cocci

Check if list iterator is reassigned.
scripts/coccinelle/iterators/list_entry_update.cocci

Check if list iterator is used after loop.
scripts/coccinelle/iterators/use_after_iter.cocci

Find wrong argument of sizeof in allocation function:
scripts/coccinelle/misc/badty.cocci

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: Add a cocci patch for miiphy_register</title>
<updated>2016-08-15T20:26:23+00:00</updated>
<author>
<name>Joe Hershberger</name>
<email>joe.hershberger@ni.com</email>
</author>
<published>2016-08-08T16:28:37+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=63d985985e383111e082c78398444941a0b9fadf'/>
<id>63d985985e383111e082c78398444941a0b9fadf</id>
<content type='text'>
Many Ethernet drivers still use the legacy miiphy API to register their
mdio interface for access to the mdio commands.

This semantic patch will convert the drivers from the legacy adapter API
to the more modern alloc/register API.

Signed-off-by: Joe Hershberger &lt;joe.hershberger@ni.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Many Ethernet drivers still use the legacy miiphy API to register their
mdio interface for access to the mdio commands.

This semantic patch will convert the drivers from the legacy adapter API
to the more modern alloc/register API.

Signed-off-by: Joe Hershberger &lt;joe.hershberger@ni.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
