Skip to contentSkip to conversation

block/vvfat.c: remove debugging code to reinit stderr if NULL

PATCH Superseded Michael Tokarev 4 participants 6 messages Aug 18, 2014 – Aug 19, 2014 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/vvfat.c: remove debugging code to reinit stderr if NULL

Just log to stderr unconditionally, like other similar code does.

---
 block/vvfat.c |    5 -----
 1 file changed, 5 deletions(-)
block/vvfat.c +0 -5
index 70176b1..ea37023 100644
@@ -1082,11 +1082,6 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
     vvv = s;
 #endif
 
-DLOG(if (stderr == NULL) {
-    stderr = fopen("vvfat.log", "a");
-    setbuf(stderr, NULL);
-})
-
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
     qemu_opts_absorb_qdict(opts, options, &local_err);
     if (local_err) {
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Michael Tokarev

Just log to stderr unconditionally, like other similar code does.

---
 block/vvfat.c |    5 -----
 1 file changed, 5 deletions(-)
block/vvfat.c +0 -6
index 70176b1..ea37023 100644
@@ -1082,11 +1082,6 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
     vvv = s;
 #endif
 
-DLOG(if (stderr == NULL) {
-    stderr = fopen("vvfat.log", "a");
-    setbuf(stderr, NULL);
-})
-
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
     qemu_opts_absorb_qdict(opts, options, &local_err);
     if (local_err) {
--
Quoted 1 line

1.7.10.4

thanks
-- PMM

#2 lore raw
In reply to Michael Tokarev

Am 18.08.2014 um 13:41 hat Michael Tokarev geschrieben:

Quoted 13 lines

Just log to stderr unconditionally, like other similar code does.

---
 block/vvfat.c |    5 -----
 1 file changed, 5 deletions(-)
block/vvfat.c +0 -0
index 70176b1..ea37023 100644
@@ -1082,11 +1082,6 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
     vvv = s;

block/vvfat.c static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, · line 1087

Quoted 10 lines
block/vvfat.c +0 -5
 #endif
 
-DLOG(if (stderr == NULL) {
-    stderr = fopen("vvfat.log", "a");
-    setbuf(stderr, NULL);
-})
-
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
     qemu_opts_absorb_qdict(opts, options, &local_err);
     if (local_err) {

Michael, it's fine to merge trivial block patches through your tree, but can you please keep Stefan and me CCed anyway?

This specific patch isn't as trivial as it might look at the first sight (in other words: it's wrong). The part that you probably missed is that stderr isn't the real one when DEBUG is set:

    #undef stderr
    #define stderr STDERR
    FILE* stderr = NULL;

So now you have a lot of fprintf(NULL, ...), which obviously makes qemu segfault as soon as you enable debugging for vvfat.

Kevin

#3 lore raw
Quoted 7 lines · Kevin Wolf

This specific patch isn't as trivial as it might look at the first sight (in other words: it's wrong). The part that you probably missed is that stderr isn't the real one when DEBUG is set:

    #undef stderr
    #define stderr STDERR
    FILE* stderr = NULL;

Yikes. Can we rip that out as well, then?

-- PMM

#4 lore raw
In reply to Kevin Wolf
Quoted 16 lines · Kevin Wolf

Am 18.08.2014 um 13:41 hat Michael Tokarev geschrieben:

block/vvfat.c static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, · line 1089

Quoted 9 lines

Just log to stderr unconditionally, like other similar code does.

block/vvfat.c +0 -5
-DLOG(if (stderr == NULL) {
-    stderr = fopen("vvfat.log", "a");
-    setbuf(stderr, NULL);
-})
-

This specific patch isn't as trivial as it might look at the first sight (in other words: it's wrong). The part that you probably missed is that stderr isn't the real one when DEBUG is set:

Quoted 3 lines
    #undef stderr
    #define stderr STDERR
    FILE* stderr = NULL;

Eeek, that's horrible. I'd rather see code doing freopen("vvfat.log", "a", stderr) than the current horrid mess of redefining stderr away from its normal meaning.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#5 lore raw

Am 19.08.2014 um 14:06 hat Eric Blake geschrieben:

Quoted 17 lines · Kevin Wolf
Quoted 16 lines

Am 18.08.2014 um 13:41 hat Michael Tokarev geschrieben:

block/vvfat.c static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, · line 1089

Quoted 9 lines

Just log to stderr unconditionally, like other similar code does.

block/vvfat.c +0 -5
-DLOG(if (stderr == NULL) {
-    stderr = fopen("vvfat.log", "a");
-    setbuf(stderr, NULL);
-})
-

This specific patch isn't as trivial as it might look at the first sight (in other words: it's wrong). The part that you probably missed is that stderr isn't the real one when DEBUG is set:

Quoted 7 lines
Quoted 3 lines
    #undef stderr
    #define stderr STDERR
    FILE* stderr = NULL;

Eeek, that's horrible. I'd rather see code doing freopen("vvfat.log", "a", stderr) than the current horrid mess of redefining stderr away from its normal meaning.

I'd vote for just removing this redefine in addition to removing the above hunk, so that everything ends up on the real stderr. But you have to do the whole thing and not just half of it.

Kevin