diff mbox

qemu-log: Remove qemu_log_try_set_file() and its users

Message ID 1360685607-8372-1-git-send-email-peter.maydell@linaro.org
State Accepted
Commit 632314c49ce20ee9c974f07544d9125fbbbfbe1b
Headers show

Commit Message

Peter Maydell Feb. 12, 2013, 4:13 p.m. UTC
Remove the function qemu_log_try_set_file() and its users (which
are all in TCG code generation functions for various targets).
This function was added to abstract out code which was originally
written as "if (!logfile) logfile = stderr;" in order that BUG:
case code which did an unguarded "fprintf(logfile, ...)" would
not crash if debug logging was not enabled. Since those direct
uses of logfile have also been abstracted away into qemu_log()
calls which check for a NULL logfile, there is no need for the
target-* files to mess with the user's chosen logging settings.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/log.h            |    8 --------
 target-cris/translate.c       |    2 --
 target-lm32/translate.c       |    2 --
 target-microblaze/translate.c |    2 --
 target-openrisc/translate.c   |    2 --
 5 files changed, 16 deletions(-)

Comments

Andreas Färber Feb. 12, 2013, 5:43 p.m. UTC | #1
Am 12.02.2013 17:13, schrieb Peter Maydell:
> Remove the function qemu_log_try_set_file() and its users (which
> are all in TCG code generation functions for various targets).
> This function was added to abstract out code which was originally
> written as "if (!logfile) logfile = stderr;" in order that BUG:
> case code which did an unguarded "fprintf(logfile, ...)" would
> not crash if debug logging was not enabled. Since those direct
> uses of logfile have also been abstracted away into qemu_log()
> calls which check for a NULL logfile, there is no need for the
> target-* files to mess with the user's chosen logging settings.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas
Michael Walle Feb. 12, 2013, 11:41 p.m. UTC | #2
Peter Maydell <peter.maydell@linaro.org> schrieb:

>Remove the function qemu_log_try_set_file() and its users (which
>are all in TCG code generation functions for various targets).
>This function was added to abstract out code which was originally
>written as "if (!logfile) logfile = stderr;" in order that BUG:
>case code which did an unguarded "fprintf(logfile, ...)" would
>not crash if debug logging was not enabled. Since those direct
>uses of logfile have also been abstracted away into qemu_log()
>calls which check for a NULL logfile, there is no need for the
>target-* files to mess with the user's chosen logging settings.
>
>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Acked-by: Michael Walle <michael@walle.cc>
Blue Swirl Feb. 16, 2013, 1:52 p.m. UTC | #3
Thanks, applied.

On Tue, Feb 12, 2013 at 4:13 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Remove the function qemu_log_try_set_file() and its users (which
> are all in TCG code generation functions for various targets).
> This function was added to abstract out code which was originally
> written as "if (!logfile) logfile = stderr;" in order that BUG:
> case code which did an unguarded "fprintf(logfile, ...)" would
> not crash if debug logging was not enabled. Since those direct
> uses of logfile have also been abstracted away into qemu_log()
> calls which check for a NULL logfile, there is no need for the
> target-* files to mess with the user's chosen logging settings.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  include/qemu/log.h            |    8 --------
>  target-cris/translate.c       |    2 --
>  target-lm32/translate.c       |    2 --
>  target-microblaze/translate.c |    2 --
>  target-openrisc/translate.c   |    2 --
>  5 files changed, 16 deletions(-)
>
> diff --git a/include/qemu/log.h b/include/qemu/log.h
> index 5a46555..4527003 100644
> --- a/include/qemu/log.h
> +++ b/include/qemu/log.h
> @@ -126,14 +126,6 @@ static inline void qemu_log_set_file(FILE *f)
>      qemu_logfile = f;
>  }
>
> -/* Set up a new log file, only if none is set */
> -static inline void qemu_log_try_set_file(FILE *f)
> -{
> -    if (!qemu_logfile) {
> -        qemu_logfile = f;
> -    }
> -}
> -
>  /* define log items */
>  typedef struct QEMULogItem {
>      int mask;
> diff --git a/target-cris/translate.c b/target-cris/translate.c
> index 09e6011..2964a21 100644
> --- a/target-cris/translate.c
> +++ b/target-cris/translate.c
> @@ -3215,8 +3215,6 @@ gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb,
>      int num_insns;
>      int max_insns;
>
> -    qemu_log_try_set_file(stderr);
> -
>      if (env->pregs[PR_VR] == 32) {
>          dc->decoder = crisv32_decoder;
>          dc->clear_locked_irq = 0;
> diff --git a/target-lm32/translate.c b/target-lm32/translate.c
> index 6b87340..ccaf838 100644
> --- a/target-lm32/translate.c
> +++ b/target-lm32/translate.c
> @@ -1012,8 +1012,6 @@ static void gen_intermediate_code_internal(CPULM32State *env,
>      int num_insns;
>      int max_insns;
>
> -    qemu_log_try_set_file(stderr);
> -
>      pc_start = tb->pc;
>      dc->env = env;
>      dc->tb = tb;
> diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
> index 58ce712..0b05264 100644
> --- a/target-microblaze/translate.c
> +++ b/target-microblaze/translate.c
> @@ -1734,8 +1734,6 @@ gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb,
>      int num_insns;
>      int max_insns;
>
> -    qemu_log_try_set_file(stderr);
> -
>      pc_start = tb->pc;
>      dc->env = env;
>      dc->tb = tb;
> diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c
> index 1e1b30c..23e853e 100644
> --- a/target-openrisc/translate.c
> +++ b/target-openrisc/translate.c
> @@ -1670,8 +1670,6 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
>      int num_insns;
>      int max_insns;
>
> -    qemu_log_try_set_file(stderr);
> -
>      pc_start = tb->pc;
>      dc->tb = tb;
>
> --
> 1.7.9.5
>
>
Peter Maydell Feb. 18, 2013, 11:36 a.m. UTC | #4
On 16 February 2013 13:52, Blue Swirl <blauwirbel@gmail.com> wrote:
> On Tue, Feb 12, 2013 at 4:13 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Remove the function qemu_log_try_set_file() and its users (which
>> are all in TCG code generation functions for various targets).

> Thanks, applied.

...this doesn't seem to be in master? The six-patch qemu-log
series is, but not this patch.

thanks
-- PMM
Blue Swirl Feb. 23, 2013, 4:48 p.m. UTC | #5
On Mon, Feb 18, 2013 at 11:36 AM, Peter Maydell
<peter.maydell@linaro.org> wrote:
> On 16 February 2013 13:52, Blue Swirl <blauwirbel@gmail.com> wrote:
>> On Tue, Feb 12, 2013 at 4:13 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>>> Remove the function qemu_log_try_set_file() and its users (which
>>> are all in TCG code generation functions for various targets).
>
>> Thanks, applied.
>
> ...this doesn't seem to be in master? The six-patch qemu-log
> series is, but not this patch.

Sorry, applied for real this time.

>
> thanks
> -- PMM
diff mbox

Patch

diff --git a/include/qemu/log.h b/include/qemu/log.h
index 5a46555..4527003 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -126,14 +126,6 @@  static inline void qemu_log_set_file(FILE *f)
     qemu_logfile = f;
 }
 
-/* Set up a new log file, only if none is set */
-static inline void qemu_log_try_set_file(FILE *f)
-{
-    if (!qemu_logfile) {
-        qemu_logfile = f;
-    }
-}
-
 /* define log items */
 typedef struct QEMULogItem {
     int mask;
diff --git a/target-cris/translate.c b/target-cris/translate.c
index 09e6011..2964a21 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -3215,8 +3215,6 @@  gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb,
     int num_insns;
     int max_insns;
 
-    qemu_log_try_set_file(stderr);
-
     if (env->pregs[PR_VR] == 32) {
         dc->decoder = crisv32_decoder;
         dc->clear_locked_irq = 0;
diff --git a/target-lm32/translate.c b/target-lm32/translate.c
index 6b87340..ccaf838 100644
--- a/target-lm32/translate.c
+++ b/target-lm32/translate.c
@@ -1012,8 +1012,6 @@  static void gen_intermediate_code_internal(CPULM32State *env,
     int num_insns;
     int max_insns;
 
-    qemu_log_try_set_file(stderr);
-
     pc_start = tb->pc;
     dc->env = env;
     dc->tb = tb;
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 58ce712..0b05264 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -1734,8 +1734,6 @@  gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb,
     int num_insns;
     int max_insns;
 
-    qemu_log_try_set_file(stderr);
-
     pc_start = tb->pc;
     dc->env = env;
     dc->tb = tb;
diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c
index 1e1b30c..23e853e 100644
--- a/target-openrisc/translate.c
+++ b/target-openrisc/translate.c
@@ -1670,8 +1670,6 @@  static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
     int num_insns;
     int max_insns;
 
-    qemu_log_try_set_file(stderr);
-
     pc_start = tb->pc;
     dc->tb = tb;