Another aspect of set_ps_display ()

From: "Strong, David" <david(dot)strong(at)unisys(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Another aspect of set_ps_display ()
Date: 2006-10-04 16:36:07
Message-ID: B6419AF36AC8524082E1BC17DA2506E80316D38C@USMV-EXCH2.na.uis.unisys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

We were just analyzing some more OProfile and ltrace data against
Postgres 8.2Beta1 and we noticed a number of calls as follows:

strlen("postgres: tpc tpc 192.168.1.200("...) = 58
memset(0xbffff6b2, '\000', 2344) = 0xbffff6b2

We have tracked this down to the following code in the set_ps_display ()
function:

#ifdef PS_USE_CLOBBER_ARGV
{
int buflen;

/* pad unused memory */
buflen = strlen(ps_buffer);
MemSet(ps_buffer + buflen, PS_PADDING, ps_buffer_size - buflen);
}
#endif /* PS_USE_CLOBBER_ARGV */

If set_ps_display () moves to use the strlcpy () function call, this
code might be redundant. Even if the StrNCpy () call is kept, this code
may still be redundant as StrNCpy () will zero fill the ps_buffer.

A MemSet () call on the ps_buffer has to be added to the init_ps_display
() function, if this code is removed to clear the buffer before use.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-10-04 16:40:55 Re: Digging gram.y
Previous Message Tom Lane 2006-10-04 16:32:46 Re: PL/pgSQL Todo, better information in errcontext from plpgsql

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-10-04 16:52:43 Re: qsort_arg needed for msvc build
Previous Message Andrew Dunstan 2006-10-04 16:12:21 Re: [PATCHES] vcbuild bison check