<feed xmlns='http://www.w3.org/2005/Atom'>
<title>qemu/scripts/coccinelle, branch master</title>
<subtitle>QEMU development tree</subtitle>
<id>https://git.zx2c4.com/qemu/atom/scripts/coccinelle?h=master</id>
<link rel='self' href='https://git.zx2c4.com/qemu/atom/scripts/coccinelle?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/'/>
<updated>2024-04-25T09:21:06Z</updated>
<entry>
<title>scripts/coccinelle: New script to add ResetType to hold and exit phases</title>
<updated>2024-04-25T09:21:06Z</updated>
<author>
<name>Peter Maydell</name>
<email>peter.maydell@linaro.org</email>
</author>
<published>2024-04-12T16:08:06Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=aadea887f4429fcc96429b126c254de94317b474'/>
<id>urn:sha1:aadea887f4429fcc96429b126c254de94317b474</id>
<content type='text'>
We pass a ResetType argument to the Resettable class enter phase
method, but we don't pass it to hold and exit, even though the
callsites have it readily available.  This means that if a device
cared about the ResetType it would need to record it in the enter
phase method to use later on.  We should pass the type to all three
of the phase methods to avoid having to do that.

This coccinelle script adds the ResetType argument to the hold and
exit phases of the Resettable interface.

The first part of the script (rules holdfn_assigned, holdfn_defined,
exitfn_assigned, exitfn_defined) update implementations of the
interface within device models, both to change the signature of their
method implementations and to pass on the reset type when they invoke
reset on some other device.

The second part of the script is various special cases:
 * method callsites in resettable_phase_hold(), resettable_phase_exit()
   and device_phases_reset()
 * updating the typedefs for the methods
 * isl_pmbus_vr.c has some code where one device's reset method directly
   calls the implementation of a different device's method

Signed-off-by: Peter Maydell &lt;peter.maydell@linaro.org&gt;
Reviewed-by: Luc Michel &lt;luc.michel@amd.com&gt;
Message-id: 20240412160809.1260625-4-peter.maydell@linaro.org
</content>
</entry>
<entry>
<title>cleanup: Tweak and re-run return_directly.cocci</title>
<updated>2022-12-14T15:19:35Z</updated>
<author>
<name>Markus Armbruster</name>
<email>armbru@redhat.com</email>
</author>
<published>2022-11-22T13:49:16Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=66997c42e02c84481fc162a5b7bd6ad6c643bae2'/>
<id>urn:sha1:66997c42e02c84481fc162a5b7bd6ad6c643bae2</id>
<content type='text'>
Tweak the semantic patch to drop redundant parenthesis around the
return expression.

Coccinelle drops a comment in hw/rdma/vmw/pvrdma_cmd.c; restored
manually.

Coccinelle messes up vmdk_co_create(), not sure why.  Change dropped,
will be done manually in the next commit.

Line breaks in target/avr/cpu.h and hw/rdma/vmw/pvrdma_cmd.c tidied up
manually.

Whitespace in tools/virtiofsd/fuse_lowlevel.c tidied up manually.

checkpatch.pl complains "return of an errno should typically be -ve"
two times for hw/9pfs/9p-synth.c.  Preexisting, the patch merely makes
it visible to checkpatch.pl.

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Message-Id: &lt;20221122134917.1217307-2-armbru@redhat.com&gt;
Reviewed-by: Philippe Mathieu-Daudé &lt;philmd@linaro.org&gt;
Acked-by: Dr. David Alan Gilbert &lt;dgilbert@redhat.com&gt;
</content>
</entry>
<entry>
<title>scripts/coccinelle: New use-g_new-etc.cocci</title>
<updated>2022-03-21T14:44:44Z</updated>
<author>
<name>Markus Armbruster</name>
<email>armbru@redhat.com</email>
</author>
<published>2022-03-15T14:41:54Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=15ba4a9f7ba592f2f1a0eb50b20f0ebd4412ab6e'/>
<id>urn:sha1:15ba4a9f7ba592f2f1a0eb50b20f0ebd4412ab6e</id>
<content type='text'>
This is the semantic patch from commit b45c03f585 "arm: Use g_new() &amp;
friends where that makes obvious sense".

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Reviewed-by: Philippe Mathieu-Daudé &lt;f4bug@amsat.org&gt;
Reviewed-by: Richard Henderson &lt;richard.henderson@linaro.org&gt;
Reviewed-by: Alex Bennée &lt;alex.bennee@linaro.org&gt;
Message-Id: &lt;20220315144156.1595462-2-armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>softmmu/memory: Pass ram_flags to memory_region_init_ram_shared_nomigrate()</title>
<updated>2021-06-15T18:27:38Z</updated>
<author>
<name>David Hildenbrand</name>
<email>david@redhat.com</email>
</author>
<published>2021-05-10T11:43:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=7f863cba4d8d35adacd513cba634dc0dd08d7904'/>
<id>urn:sha1:7f863cba4d8d35adacd513cba634dc0dd08d7904</id>
<content type='text'>
Let's forward ram_flags instead, renaming
memory_region_init_ram_shared_nomigrate() into
memory_region_init_ram_flags_nomigrate().

Reviewed-by: Philippe Mathieu-Daudé &lt;philmd@redhat.com&gt;
Reviewed-by: Peter Xu &lt;peterx@redhat.com&gt;
Acked-by: Eduardo Habkost &lt;ehabkost@redhat.com&gt; for memory backend and machine core
Signed-off-by: David Hildenbrand &lt;david@redhat.com&gt;
Message-Id: &lt;20210510114328.21835-6-david@redhat.com&gt;
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
</content>
</entry>
<entry>
<title>scripts/coccinelle: New script to remove unnecessary timer_del() calls</title>
<updated>2021-01-08T15:13:38Z</updated>
<author>
<name>Peter Maydell</name>
<email>peter.maydell@linaro.org</email>
</author>
<published>2020-12-15T15:41:05Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=01b3e68bb18d1a37f013ffac41423faa7c00958f'/>
<id>urn:sha1:01b3e68bb18d1a37f013ffac41423faa7c00958f</id>
<content type='text'>
Now that timer_free() implicitly calls timer_del(), sequences
  timer_del(mytimer);
  timer_free(mytimer);

can be simplified to just
  timer_free(mytimer);

Add a Coccinelle script to do this transformation.

Signed-off-by: Peter Maydell &lt;peter.maydell@linaro.org&gt;
Acked-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Reviewed-by: Philippe Mathieu-Daudé &lt;philmd@redhat.com&gt;
Reviewed-by: Richard Henderson &lt;richard.henderson@linaro.org&gt;
Message-id: 20201215154107.3255-3-peter.maydell@linaro.org
</content>
</entry>
<entry>
<title>qom: fix objects with improper parent type</title>
<updated>2020-10-12T15:50:22Z</updated>
<author>
<name>Paolo Bonzini</name>
<email>pbonzini@redhat.com</email>
</author>
<published>2020-10-07T16:23:56Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=22fb6eb571387172f41878866f4438b6bae21f0e'/>
<id>urn:sha1:22fb6eb571387172f41878866f4438b6bae21f0e</id>
<content type='text'>
Some objects accidentally inherit ObjectClass instead of Object.
They compile silently but may crash after downcasting.

In this patch, we introduce a coccinelle script to find broken
declarations and fix them manually with proper base type.

Signed-off-by: Sergey Nizovtsev &lt;snizovtsev@gmail.com&gt;
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
</content>
</entry>
<entry>
<title>coccinelle/err-bad-newline: Fix for Python 3, and add patterns</title>
<updated>2020-07-24T10:56:44Z</updated>
<author>
<name>Markus Armbruster</name>
<email>armbru@redhat.com</email>
</author>
<published>2020-07-22T08:40:45Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=cb3fa1e4c05a4ad2563b39cdb1146e617f3b5424'/>
<id>urn:sha1:cb3fa1e4c05a4ad2563b39cdb1146e617f3b5424</id>
<content type='text'>
Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Message-Id: &lt;20200722084048.1726105-2-armbru@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
</content>
</entry>
<entry>
<title>scripts: Coccinelle script to use ERRP_GUARD()</title>
<updated>2020-07-10T13:18:09Z</updated>
<author>
<name>Vladimir Sementsov-Ogievskiy</name>
<email>vsementsov@virtuozzo.com</email>
</author>
<published>2020-07-07T16:50:31Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=8220f3ac74a4698b0734aa882e74c5d9337e3d99'/>
<id>urn:sha1:8220f3ac74a4698b0734aa882e74c5d9337e3d99</id>
<content type='text'>
Script adds ERRP_GUARD() macro invocations where appropriate and
does corresponding changes in code (look for details in
include/qapi/error.h)

Usage example:
spatch --sp-file scripts/coccinelle/errp-guard.cocci \
 --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff \
 --max-width 80 FILES...

Signed-off-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@virtuozzo.com&gt;
Reviewed-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Message-Id: &lt;20200707165037.1026246-3-armbru@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
[ERRP_AUTO_PROPAGATE() renamed to ERRP_GUARD(), and
auto-propagated-errp.cocci to errp-guard.cocci]
</content>
</entry>
<entry>
<title>scripts/coccinelle: add error-use-after-free.cocci</title>
<updated>2020-04-04T12:14:09Z</updated>
<author>
<name>Vladimir Sementsov-Ogievskiy</name>
<email>vsementsov@virtuozzo.com</email>
</author>
<published>2020-03-24T15:36:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=d1d3a99795006d81f10c98927b0c2ad270bc78fd'/>
<id>urn:sha1:d1d3a99795006d81f10c98927b0c2ad270bc78fd</id>
<content type='text'>
Add script to find and fix trivial use-after-free of Error objects.
How to use:
spatch --sp-file scripts/coccinelle/error-use-after-free.cocci \
 --macro-file scripts/cocci-macro-file.h --in-place \
 --no-show-diff ( FILES... | --use-gitgrep . )

Signed-off-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@virtuozzo.com&gt;
Message-Id: &lt;20200324153630.11882-2-vsementsov@virtuozzo.com&gt;
Reviewed-by: Richard Henderson &lt;richard.henderson@linaro.org&gt;
Reviewed-by: Markus Armbruster &lt;armbru@redhat.com&gt;
[Pastos in commit message and comment fixed, globbing in MAINTAINERS
expanded]
Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>cpu: Use DeviceClass reset instead of a special CPUClass reset</title>
<updated>2020-03-17T23:48:10Z</updated>
<author>
<name>Peter Maydell</name>
<email>peter.maydell@linaro.org</email>
</author>
<published>2020-03-03T10:05:11Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=781c67ca5585b38a29076093ecdff4f273db5a35'/>
<id>urn:sha1:781c67ca5585b38a29076093ecdff4f273db5a35</id>
<content type='text'>
The CPUClass has a 'reset' method.  This is a legacy from when
TYPE_CPU used not to inherit from TYPE_DEVICE.  We don't need it any
more, as we can simply use the TYPE_DEVICE reset.  The 'cpu_reset()'
function is kept as the API which most places use to reset a CPU; it
is now a wrapper which calls device_cold_reset() and then the
tracepoint function.

This change should not cause CPU objects to be reset more often
than they are at the moment, because:
 * nobody is directly calling device_cold_reset() or
   qdev_reset_all() on CPU objects
 * no CPU object is on a qbus, so they will not be reset either
   by somebody calling qbus_reset_all()/bus_cold_reset(), or
   by the main "reset sysbus and everything in the qbus tree"
   reset that most devices are reset by

Note that this does not change the need for each machine or whatever
to use qemu_register_reset() to arrange to call cpu_reset() -- that
is necessary because CPU objects are not on any qbus, so they don't
get reset when the qbus tree rooted at the sysbus bus is reset, and
this isn't being changed here.

All the changes to the files under target/ were made using the
included Coccinelle script, except:

(1) the deletion of the now-inaccurate and not terribly useful
"CPUClass::reset" comments was done with a perl one-liner afterwards:
  perl -n -i -e '/ CPUClass::reset/ or print' target/*/*.c

(2) this bit of the s390 change was done by hand, because the
Coccinelle script is not sophisticated enough to handle the
parent_reset call being inside another function:

| @@ -96,8 +96,9 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
|     S390CPU *cpu = S390_CPU(s);
|     S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
|     CPUS390XState *env = &amp;cpu-&gt;env;
|+    DeviceState *dev = DEVICE(s);
|
|-    scc-&gt;parent_reset(s);
|+    scc-&gt;parent_reset(dev);
|     cpu-&gt;env.sigp_order = 0;
|     s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu);

Signed-off-by: Peter Maydell &lt;peter.maydell@linaro.org&gt;
Message-Id: &lt;20200303100511.5498-1-peter.maydell@linaro.org&gt;
Reviewed-by: Philippe Mathieu-Daudé &lt;philmd@redhat.com&gt;
Reviewed-by: Richard Henderson &lt;richard.henderson@linaro.org&gt;
Tested-by: Philippe Mathieu-Daudé &lt;philmd@redhat.com&gt;
Signed-off-by: Eduardo Habkost &lt;ehabkost@redhat.com&gt;
</content>
</entry>
</feed>
