[SSSD] [PATCH] Simplify debug_fn()
Sumit Bose
sbose at redhat.com
Wed Nov 4 19:11:41 UTC 2009
On Wed, Nov 04, 2009 at 02:01:44PM -0500, Stephen Gallagher wrote:
>
> We don't need to be allocating an output string here. This was
> also causing a runtime bug when the output string contained
> characters that would be interpreted by fprintf as specifiers.
>
> --
> Stephen Gallagher
> RHCE 804006346421761
>
> Delivering value year after year.
> Red Hat ranks #1 in value among software vendors.
> http://www.redhat.com/promo/vendor/
> From 6934b72a4521d8c4aeb9edab8cfb87897007b114 Mon Sep 17 00:00:00 2001
> From: Stephen Gallagher <sgallagh at redhat.com>
> Date: Wed, 4 Nov 2009 14:00:03 -0500
> Subject: [PATCH] Simplify debug_fn()
>
> We don't need to be allocating an output string here. This was
> also causing a runtime bug when the output string contained
> characters that would be interpreted by fprintf as specifiers.
> ---
> server/util/debug.c | 13 ++-----------
> 1 files changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/server/util/debug.c b/server/util/debug.c
> index 862367c..f41af4b 100644
> --- a/server/util/debug.c
> +++ b/server/util/debug.c
> @@ -56,23 +56,14 @@ errno_t set_debug_file_from_fd(const int fd)
> void debug_fn(const char *format, ...)
> {
> va_list ap;
> - char *s = NULL;
> int ret;
Please remove 'ret', too. Otherwise it is working well: ACK
bye,
Sumit
>
> va_start(ap, format);
>
> - ret = vasprintf(&s, format, ap);
> - if (ret < 0) {
> - /* ENOMEM */
> - return;
> - }
> + vfprintf(debug_file ? debug_file : stderr, format, ap);
> + fflush(debug_file ? debug_file : stderr);
>
> va_end(ap);
> -
> - /*write(state.fd, s, strlen(s));*/
> - fprintf(debug_file ? debug_file : stderr, s);
> - fflush(debug_file ? debug_file : stderr);
> - free(s);
> }
>
> void ldb_debug_messages(void *context, enum ldb_debug_level level,
> --
> 1.6.2.5
>
> _______________________________________________
> sssd-devel mailing list
> sssd-devel at lists.fedorahosted.org
> https://fedorahosted.org/mailman/listinfo/sssd-devel
More information about the sssd-devel
mailing list