Using memset or other way in sal/osl/unx/security.c

Norbert Thiebaud nthiebaud at gmail.com
Mon Dec 24 09:08:17 PST 2012


On Mon, Dec 24, 2012 at 8:59 AM, julien2412 <serval2412 at yahoo.fr> wrote:
> Hello,
>
> In sal/osl/unx/security.c, I noticed these:
>     278 sal_Bool SAL_CALL osl_getHomeDir(oslSecurity Security, rtl_uString
> **pustrDirectory)
>     279 {
>     280     sal_Bool bRet=sal_False;
>     281     sal_Char pszDirectory[PATH_MAX];
>     282
>     283     pszDirectory[0] = '\0';
>
>     373 sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString
> **pustrDirectory)
>     374 {
>     375     sal_Bool bRet = sal_False;
>     376     sal_Char pszDirectory[PATH_MAX];
>     377
>     378     pszDirectory[0] = '\0';
>
> I'm not sure but I think it doesn't put the rest of the array to 0.
> Would memsetting to 0 the whole array be right (and possibly useful)?

What issue are you trying to solve ? i'm not sure as to the purpose of
memsetting 512-1024 bytes

> What about this too ?
> sal_Char pszDirectory[PATH_MAX] = "";
> It compiles but I wonder if it would be ok for every env

blanc-bonnet et bonnet-blanc :-)
although I don't know if the compiler is smart enough to avoid having
an actual literal string of len 0 rather than just putting 0 in the
first byte of the local variable.

iow it would not change anything 'functionally' and at best it would
be  a wash as far as generated code.

Norbert


More information about the LibreOffice mailing list