diff mbox

[0/3] tighten scope of accidentally global variables

Message ID 877gw5l6m8.fsf@rho.meyering.net
State New
Headers show

Commit Message

Jim Meyering May 21, 2012, 6:41 p.m. UTC
Blue Swirl wrote:
> On Mon, May 21, 2012 at 6:10 PM, Jim Meyering <jim@meyering.net> wrote:
>> Blue Swirl wrote:
>>> On Mon, May 21, 2012 at 10:03 AM, Jim Meyering <jim@meyering.net> wrote:
>>>> From: Jim Meyering <meyering@redhat.com>
>>>>
>>>> I noticed this commit,
>>>>
>>>>    virtio-pci: add missing 'static'
>>>>
>>>> which made this change:
>>>>
>>>>    > -const MemoryRegionPortio virtio_portio[] = {
>>>>    > +static const MemoryRegionPortio virtio_portio[] = {
>>>>
>>>> and wondered if there were other variables like that.
>>>> The following command shows that there are:
>>>> [note that there are probably more: this finds only those
>>>>  for which the variable name appears in only one source file. ]
>>>
>>> Also, only for files at the top level.
>>
>> Thanks.  There were so many .o files, I assumed that all were at the top.
>> Searching all .o files, I found many more:
>>
>>  $ for i in $(nm -e $(find . -name '*.o')|sed -n 's/.* [BCDGRS] //p'|sort -u);\
>>    do test $(git grep -lw $i|wc -l) = 1 && echo $i;done
>
> How about just checking the executables (*-softmmu/qemu-system-xyz and
> linux-user/qemu-xyz)?

If I understood what you suggest, that would seem to miss only "test_image":
(README-scope-vars is the result of the one above using find and *.o)

$ for i in $(nm -e *-softmmu/qemu-system-* linux-user/qemu-*|sed -n 's/.* [BCDGRS] //p'|sort -u); do test $(git grep -lw $i|wc -l) = 1 && echo $i;done > k
nm: linux-user/qemu-types.h: File format not recognized
[Exit 1]
$ diff -u k README-scope-vars
diff mbox

Patch

--- k   2012-05-21 20:38:15.912149444 +0200
+++ README-scope-vars   2012-05-21 20:12:13.270023293 +0200
@@ -53,6 +62,7 @@  rtas_next
 s390_virtio_bus_info
 sh_table
 special_register_prefix
+test_image
 timers_state
 v9fs_synth_root
 virtcon_hds