Subject: bug#6420: Some enhancements to debugging

From: Eli Zaretskii <[email-masked]>
Date: Mon, 14 Jun 2010 20:58:33 +0300

> From: Lennart Borgman <[email-masked]>
> Date: Mon, 14 Jun 2010 08:11:59 +0200
> Cc: 
> 
> === modified file 'src/w32proc.c'
> --- trunk/src/w32proc.c	2010-06-04 14:13:35 +0000
> +++ patched/src/w32proc.c	2010-06-14 05:53:50 +0000
> @@ -121,9 +121,17 @@
>  {
>    char buf[1024];
>    va_list args;
> +  char *buf_pos = buf;
> +
> +  /* On NT add thread id */
> +#ifdef WINDOWSNT
> +  DWORD thread_id = GetCurrentThreadId ();
> +  sprintf (buf_pos, "[Th%04x]  ", thread_id);
> +  buf_pos = buf_pos + 10;
> +#endif

The above #ifdef is unnecessary: all the platforms that compile this
file have WINDOWSNT defined by definition.

Also, why do you use magic constants such as 10, instead of the value
returned by `sprintf'?

> -	  DebPrint (("reader_thread.SetEvent failed with %lu for fd %ld\n",
> -		     GetLastError (), cp->fd));
> +	  DebPrint (("reader_thread.SetEvent failed with %lu for fd %ld, pid %ld\n",
> +		     GetLastError (), cp->fd, cp->pid));

cp->fd and cp->pid are both `int', so no need for `l' in `%ld'.  Just
use `%d'.

> +If the message is longer than 1000 chars it will be split in several
> +lines.

Not really 1000, since you are prepending a thread ID, no?