* [Qemu-devel] [PATCH] block: Clean up some bad code in the vvfat driver
@ 2017-09-13 10:21 Thomas Huth
2017-09-13 13:57 ` Eric Blake
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Thomas Huth @ 2017-09-13 10:21 UTC (permalink / raw)
To: Kevin Wolf, qemu-block; +Cc: Max Reitz, qemu-devel
Remove the unnecessary home-grown redefinition of the assert() macro here,
and remove the unusable debug code at the end of the checkpoint() function.
The code there uses assert() with side-effects (assignment to the "mapping"
variable), which should be avoided. Looking more closely, it seems as it is
apparently also only usable for one certain directory layout (with a file
named USB.H in it) and thus is of no use for the rest of the world.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
block/vvfat.c | 26 ++------------------------
1 file changed, 2 insertions(+), 24 deletions(-)
diff --git a/block/vvfat.c b/block/vvfat.c
index c54fa94..777a8cd 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -56,15 +56,6 @@
static void checkpoint(void);
-#ifdef __MINGW32__
-void nonono(const char* file, int line, const char* msg) {
- fprintf(stderr, "Nonono! %s:%d %s\n", file, line, msg);
- exit(-5);
-}
-#undef assert
-#define assert(a) do {if (!(a)) nonono(__FILE__, __LINE__, #a);}while(0)
-#endif
-
#else
#define DLOG(a)
@@ -3269,24 +3260,11 @@ static void bdrv_vvfat_init(void)
block_init(bdrv_vvfat_init);
#ifdef DEBUG
-static void checkpoint(void) {
+static void checkpoint(void)
+{
assert(((mapping_t*)array_get(&(vvv->mapping), 0))->end == 2);
check1(vvv);
check2(vvv);
assert(!vvv->current_mapping || vvv->current_fd || (vvv->current_mapping->mode & MODE_DIRECTORY));
-#if 0
- if (((direntry_t*)vvv->directory.pointer)[1].attributes != 0xf)
- fprintf(stderr, "Nonono!\n");
- mapping_t* mapping;
- direntry_t* direntry;
- assert(vvv->mapping.size >= vvv->mapping.item_size * vvv->mapping.next);
- assert(vvv->directory.size >= vvv->directory.item_size * vvv->directory.next);
- if (vvv->mapping.next<47)
- return;
- assert((mapping = array_get(&(vvv->mapping), 47)));
- assert(mapping->dir_index < vvv->directory.next);
- direntry = array_get(&(vvv->directory), mapping->dir_index);
- assert(!memcmp(direntry->name, "USB H ", 11) || direntry->name[0]==0);
-#endif
}
#endif
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: Clean up some bad code in the vvfat driver
2017-09-13 10:21 [Qemu-devel] [PATCH] block: Clean up some bad code in the vvfat driver Thomas Huth
@ 2017-09-13 13:57 ` Eric Blake
2017-09-13 19:08 ` [Qemu-devel] [Qemu-block] " John Snow
2017-09-19 8:02 ` [Qemu-devel] " Kevin Wolf
2 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2017-09-13 13:57 UTC (permalink / raw)
To: Thomas Huth, Kevin Wolf, qemu-block; +Cc: qemu-devel, Max Reitz
[-- Attachment #1: Type: text/plain, Size: 853 bytes --]
On 09/13/2017 05:21 AM, Thomas Huth wrote:
> Remove the unnecessary home-grown redefinition of the assert() macro here,
> and remove the unusable debug code at the end of the checkpoint() function.
> The code there uses assert() with side-effects (assignment to the "mapping"
> variable), which should be avoided. Looking more closely, it seems as it is
> apparently also only usable for one certain directory layout (with a file
> named USB.H in it) and thus is of no use for the rest of the world.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> block/vvfat.c | 26 ++------------------------
> 1 file changed, 2 insertions(+), 24 deletions(-)
>
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] block: Clean up some bad code in the vvfat driver
2017-09-13 10:21 [Qemu-devel] [PATCH] block: Clean up some bad code in the vvfat driver Thomas Huth
2017-09-13 13:57 ` Eric Blake
@ 2017-09-13 19:08 ` John Snow
2017-09-19 8:06 ` Paolo Bonzini
2017-09-19 8:02 ` [Qemu-devel] " Kevin Wolf
2 siblings, 1 reply; 10+ messages in thread
From: John Snow @ 2017-09-13 19:08 UTC (permalink / raw)
To: Thomas Huth, Kevin Wolf, qemu-block; +Cc: qemu-devel, Max Reitz
On 09/13/2017 06:21 AM, Thomas Huth wrote:
> Remove the unnecessary home-grown redefinition of the assert() macro here,
> and remove the unusable debug code at the end of the checkpoint() function.
> The code there uses assert() with side-effects (assignment to the "mapping"
> variable), which should be avoided. Looking more closely, it seems as it is
> apparently also only usable for one certain directory layout (with a file
> named USB.H in it) and thus is of no use for the rest of the world.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Farewell, bitrot code.
Reviewed-by: John Snow <jsnow@redhat.com>
Out of curiosity, I wonder ...
jhuston@probe (foobar) ~/s/qemu> git grep '#if 0' | wc -l
320
oh no
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] block: Clean up some bad code in the vvfat driver
2017-09-13 19:08 ` [Qemu-devel] [Qemu-block] " John Snow
@ 2017-09-19 8:06 ` Paolo Bonzini
2017-09-19 8:14 ` [Qemu-devel] Dead code in cpu-models.h (was: block: Clean up some bad code in the vvfat driver) Thomas Huth
2017-09-19 19:01 ` [Qemu-devel] [Qemu-block] [PATCH] block: Clean up some bad code in the vvfat driver John Snow
0 siblings, 2 replies; 10+ messages in thread
From: Paolo Bonzini @ 2017-09-19 8:06 UTC (permalink / raw)
To: John Snow, Thomas Huth, Kevin Wolf, qemu-block; +Cc: qemu-devel, Max Reitz
On 13/09/2017 21:08, John Snow wrote:
>
>
> On 09/13/2017 06:21 AM, Thomas Huth wrote:
>> Remove the unnecessary home-grown redefinition of the assert() macro here,
>> and remove the unusable debug code at the end of the checkpoint() function.
>> The code there uses assert() with side-effects (assignment to the "mapping"
>> variable), which should be avoided. Looking more closely, it seems as it is
>> apparently also only usable for one certain directory layout (with a file
>> named USB.H in it) and thus is of no use for the rest of the world.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>
> Farewell, bitrot code.
>
> Reviewed-by: John Snow <jsnow@redhat.com>
>
> Out of curiosity, I wonder ...
>
> jhuston@probe (foobar) ~/s/qemu> git grep '#if 0' | wc -l
> 320
$ git grep -c '#if 0' | sort -k2 --field-separator=: -n
...
hw/net/eepro100.c:21
target/ppc/cpu-models.h:76
whoa :)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] Dead code in cpu-models.h (was: block: Clean up some bad code in the vvfat driver)
2017-09-19 8:06 ` Paolo Bonzini
@ 2017-09-19 8:14 ` Thomas Huth
2017-09-19 18:54 ` [Qemu-devel] Dead code in cpu-models.h John Snow
2017-09-19 19:01 ` [Qemu-devel] [Qemu-block] [PATCH] block: Clean up some bad code in the vvfat driver John Snow
1 sibling, 1 reply; 10+ messages in thread
From: Thomas Huth @ 2017-09-19 8:14 UTC (permalink / raw)
To: Paolo Bonzini, John Snow, Kevin Wolf, qemu-block
Cc: qemu-devel, Max Reitz, Igor Mammedov, qemu-ppc
On 19.09.2017 10:06, Paolo Bonzini wrote:
> On 13/09/2017 21:08, John Snow wrote:
[...]
>> Farewell, bitrot code.
>>
>> Reviewed-by: John Snow <jsnow@redhat.com>
>>
>> Out of curiosity, I wonder ...
>>
>> jhuston@probe (foobar) ~/s/qemu> git grep '#if 0' | wc -l
>> 320
>
> $ git grep -c '#if 0' | sort -k2 --field-separator=: -n
> ...
> hw/net/eepro100.c:21
> target/ppc/cpu-models.h:76
>
> whoa :)
Igor recently already removed the dead definitions from cpu-models.c :
https://git.qemu.org/?p=qemu.git;a=commitdiff;h=aef779605779579afbafff
I guess we could now remove the corresponding dead definitions from the
header, too...
Any volunteers?
Thomas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Dead code in cpu-models.h
2017-09-19 8:14 ` [Qemu-devel] Dead code in cpu-models.h (was: block: Clean up some bad code in the vvfat driver) Thomas Huth
@ 2017-09-19 18:54 ` John Snow
2017-09-19 19:05 ` Thomas Huth
0 siblings, 1 reply; 10+ messages in thread
From: John Snow @ 2017-09-19 18:54 UTC (permalink / raw)
To: Thomas Huth, Paolo Bonzini, Kevin Wolf, qemu-block
Cc: Igor Mammedov, qemu-ppc, qemu-devel, Max Reitz
On 09/19/2017 04:14 AM, Thomas Huth wrote:
> On 19.09.2017 10:06, Paolo Bonzini wrote:
>> On 13/09/2017 21:08, John Snow wrote:
> [...]
>>> Farewell, bitrot code.
>>>
>>> Reviewed-by: John Snow <jsnow@redhat.com>
>>>
>>> Out of curiosity, I wonder ...
>>>
>>> jhuston@probe (foobar) ~/s/qemu> git grep '#if 0' | wc -l
>>> 320
>>
>> $ git grep -c '#if 0' | sort -k2 --field-separator=: -n
>> ...
>> hw/net/eepro100.c:21
>> target/ppc/cpu-models.h:76
>>
>> whoa :)
>
> Igor recently already removed the dead definitions from cpu-models.c :
>
> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=aef779605779579afbafff
>
> I guess we could now remove the corresponding dead definitions from the
> header, too...
>
> Any volunteers?
>
> Thomas
>
Well, I can just take a chainsaw to it blindly if you want to critique it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Dead code in cpu-models.h
2017-09-19 18:54 ` [Qemu-devel] Dead code in cpu-models.h John Snow
@ 2017-09-19 19:05 ` Thomas Huth
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2017-09-19 19:05 UTC (permalink / raw)
To: John Snow, Paolo Bonzini, Kevin Wolf, qemu-block
Cc: Igor Mammedov, qemu-ppc, qemu-devel, Max Reitz
On 19.09.2017 20:54, John Snow wrote:
>
>
> On 09/19/2017 04:14 AM, Thomas Huth wrote:
>> On 19.09.2017 10:06, Paolo Bonzini wrote:
>>> On 13/09/2017 21:08, John Snow wrote:
>> [...]
>>>> Farewell, bitrot code.
>>>>
>>>> Reviewed-by: John Snow <jsnow@redhat.com>
>>>>
>>>> Out of curiosity, I wonder ...
>>>>
>>>> jhuston@probe (foobar) ~/s/qemu> git grep '#if 0' | wc -l
>>>> 320
>>>
>>> $ git grep -c '#if 0' | sort -k2 --field-separator=: -n
>>> ...
>>> hw/net/eepro100.c:21
>>> target/ppc/cpu-models.h:76
>>>
>>> whoa :)
>>
>> Igor recently already removed the dead definitions from cpu-models.c :
>>
>> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=aef779605779579afbafff
>>
>> I guess we could now remove the corresponding dead definitions from the
>> header, too...
>>
>> Any volunteers?
>>
>> Thomas
>
> Well, I can just take a chainsaw to it blindly if you want to critique it.
>
I think it should at least be aligned with the changes that have been
done to cpu-models.c (e.g. the definition for CPU_POWERPC_401B3 has been
removed from the .c file, so the CPU_POWERPC_401B3 could be removed from
the .h file, too.
Thomas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] block: Clean up some bad code in the vvfat driver
2017-09-19 8:06 ` Paolo Bonzini
2017-09-19 8:14 ` [Qemu-devel] Dead code in cpu-models.h (was: block: Clean up some bad code in the vvfat driver) Thomas Huth
@ 2017-09-19 19:01 ` John Snow
2017-09-19 19:08 ` Thomas Huth
1 sibling, 1 reply; 10+ messages in thread
From: John Snow @ 2017-09-19 19:01 UTC (permalink / raw)
To: Paolo Bonzini, Thomas Huth, Kevin Wolf, qemu-block; +Cc: qemu-devel, Max Reitz
On 09/19/2017 04:06 AM, Paolo Bonzini wrote:
> On 13/09/2017 21:08, John Snow wrote:
>>
>>
>> On 09/13/2017 06:21 AM, Thomas Huth wrote:
>>> Remove the unnecessary home-grown redefinition of the assert() macro here,
>>> and remove the unusable debug code at the end of the checkpoint() function.
>>> The code there uses assert() with side-effects (assignment to the "mapping"
>>> variable), which should be avoided. Looking more closely, it seems as it is
>>> apparently also only usable for one certain directory layout (with a file
>>> named USB.H in it) and thus is of no use for the rest of the world.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>
>> Farewell, bitrot code.
>>
>> Reviewed-by: John Snow <jsnow@redhat.com>
>>
>> Out of curiosity, I wonder ...
>>
>> jhuston@probe (foobar) ~/s/qemu> git grep '#if 0' | wc -l
>> 320
>
>
> $ git grep -c '#if 0' | sort -k2 --field-separator=: -n
> ...
> hw/net/eepro100.c:21
> target/ppc/cpu-models.h:76
>
> whoa :)
>
Wonder if '#if 0' should be against the style guide / in checkpatch.
Conditional compilations should at least be contingent on some named
variable/condition.
(Probably super ideally all conditional compilations correlate directly
to a configure variable...)
--js
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] block: Clean up some bad code in the vvfat driver
2017-09-19 19:01 ` [Qemu-devel] [Qemu-block] [PATCH] block: Clean up some bad code in the vvfat driver John Snow
@ 2017-09-19 19:08 ` Thomas Huth
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2017-09-19 19:08 UTC (permalink / raw)
To: John Snow, Paolo Bonzini, Kevin Wolf, qemu-block; +Cc: qemu-devel, Max Reitz
On 19.09.2017 21:01, John Snow wrote:
>
>
> On 09/19/2017 04:06 AM, Paolo Bonzini wrote:
>> On 13/09/2017 21:08, John Snow wrote:
>>>
>>>
>>> On 09/13/2017 06:21 AM, Thomas Huth wrote:
>>>> Remove the unnecessary home-grown redefinition of the assert() macro here,
>>>> and remove the unusable debug code at the end of the checkpoint() function.
>>>> The code there uses assert() with side-effects (assignment to the "mapping"
>>>> variable), which should be avoided. Looking more closely, it seems as it is
>>>> apparently also only usable for one certain directory layout (with a file
>>>> named USB.H in it) and thus is of no use for the rest of the world.
>>>>
>>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>>
>>> Farewell, bitrot code.
>>>
>>> Reviewed-by: John Snow <jsnow@redhat.com>
>>>
>>> Out of curiosity, I wonder ...
>>>
>>> jhuston@probe (foobar) ~/s/qemu> git grep '#if 0' | wc -l
>>> 320
>>
>>
>> $ git grep -c '#if 0' | sort -k2 --field-separator=: -n
>> ...
>> hw/net/eepro100.c:21
>> target/ppc/cpu-models.h:76
>>
>> whoa :)
>>
>
> Wonder if '#if 0' should be against the style guide / in checkpatch.
checkpatch already complains if you have a "#if 0" in your patch, so I
think we should be pretty fine here already - but of course you can
still add a paragraph to the CODING_STYLE if you like.
Thomas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] block: Clean up some bad code in the vvfat driver
2017-09-13 10:21 [Qemu-devel] [PATCH] block: Clean up some bad code in the vvfat driver Thomas Huth
2017-09-13 13:57 ` Eric Blake
2017-09-13 19:08 ` [Qemu-devel] [Qemu-block] " John Snow
@ 2017-09-19 8:02 ` Kevin Wolf
2 siblings, 0 replies; 10+ messages in thread
From: Kevin Wolf @ 2017-09-19 8:02 UTC (permalink / raw)
To: Thomas Huth; +Cc: qemu-block, Max Reitz, qemu-devel
Am 13.09.2017 um 12:21 hat Thomas Huth geschrieben:
> Remove the unnecessary home-grown redefinition of the assert() macro here,
> and remove the unusable debug code at the end of the checkpoint() function.
> The code there uses assert() with side-effects (assignment to the "mapping"
> variable), which should be avoided. Looking more closely, it seems as it is
> apparently also only usable for one certain directory layout (with a file
> named USB.H in it) and thus is of no use for the rest of the world.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-09-19 19:08 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-13 10:21 [Qemu-devel] [PATCH] block: Clean up some bad code in the vvfat driver Thomas Huth
2017-09-13 13:57 ` Eric Blake
2017-09-13 19:08 ` [Qemu-devel] [Qemu-block] " John Snow
2017-09-19 8:06 ` Paolo Bonzini
2017-09-19 8:14 ` [Qemu-devel] Dead code in cpu-models.h (was: block: Clean up some bad code in the vvfat driver) Thomas Huth
2017-09-19 18:54 ` [Qemu-devel] Dead code in cpu-models.h John Snow
2017-09-19 19:05 ` Thomas Huth
2017-09-19 19:01 ` [Qemu-devel] [Qemu-block] [PATCH] block: Clean up some bad code in the vvfat driver John Snow
2017-09-19 19:08 ` Thomas Huth
2017-09-19 8:02 ` [Qemu-devel] " Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).