Dvolgyes fixes

Hi,

Please, review these fixes I made. They are basically string and memory handling related changes:
- some str*cpy change: size parameter, NUL termination, etc.
- snprintf: the size of the memory region contains the last \0, so there is no need for .... ,SIZE-1, like constants
- sometimes strncpy is just a slow implementation of memcpy
  (e.g. len=strlen(source); strncpy(target,source,len);  
   In this case strncpy will NOT copy the last \0, therefore memcpy is fine. (Or strcpy without strlen, it depends on the situation.))
 - some other small fixes.

Environment: I tested the code with tokyocabinet, using Ubuntu 12.04 (x64), gcc 4.6.3


Yes, that's right. However, it also could/should be "const", I guess.
Both "const char* " or "const char helper[]" look fine for me.


On Thu, Jun 12, 2014 at 1:41 PM, Edward Welbourne <notifications@github.com>
wrote:

> In tests/unit/redirection_test.c:
>
> > @@ -71,7 +71,7 @@ int main(int argc, char **argv)
> >      PRINT_TEST_BANNER();
> >      /* Find the proper path for our helper */
> >      char *base = dirname(argv[0]);
> > -    char helper = "/redirection_test_stub";
> > +    char *helper = "/redirection_test_stub";
>
> I'm amazed the previous form compiled ! However, your change assigns a
> string literal (of type const char*) to a (non-const) char * variable,
> which shall get warnings. Better to use the string as initializer for an
> array:
>
> char helper[] = "/redirection_test_stub";
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/cfengine/core/pull/1433/files#r13697117>.
>