Re: Bug#644657: libmemcached: FTBFS on hurd-i386
Hi!
On Thu, 2011-10-13 at 19:00:24 +0200, Svante Signell wrote:
> Attached is an updated patch, mainly fixing some indentation and coding
> style issues and not limiting msghdr if there is no IOV_MAX limit
> defined (as on GNU/Hurd).
> diff -ur libmemcached-0.44//clients/ms_conn.c libmemcached-0.44.modified//clients/ms_conn.c
> --- libmemcached-0.44//clients/ms_conn.c 2010-07-22 17:06:58.000000000 +0200
> +++ libmemcached-0.44.modified//clients/ms_conn.c 2011-10-13 17:47:16.000000000 +0200
> @@ -2125,12 +2125,14 @@
> limit_to_mtu= c->udp;
>
> /* We may need to start a new msghdr if this one is full. */
> +#ifdef IOV_MAX
> if ((m->msg_iovlen == IOV_MAX)
> || (limit_to_mtu && (c->msgbytes >= UDP_MAX_SEND_PAYLOAD_SIZE)))
> {
> ms_add_msghdr(c);
> m= &c->msglist[c->msgused - 1];
> }
> +#endif
Sorry, I guess I was not clear with my comment, I meant that the
IOV_MAX specific condition should not be honoured when there's no such
limit, the other part of the condition is still relevant though (the MTU
limit), and a new header should be started then.
> diff -ur libmemcached-0.44//clients/ms_setting.c libmemcached-0.44.modified//clients/ms_setting.c
> --- libmemcached-0.44//clients/ms_setting.c 2010-08-03 02:34:02.000000000 +0200
> +++ libmemcached-0.44.modified//clients/ms_setting.c 2011-10-13 18:20:53.000000000 +0200
> @@ -304,13 +304,17 @@
> */
> static void ms_no_config_file()
> {
> - char userpath[PATH_MAX];
> + char *userpath= NULL;
> + size_t len;
> struct passwd *usr= NULL;
> FILE *fd;
>
> usr= getpwuid(getuid());
>
> - snprintf(userpath, PATH_MAX, "%s/%s", usr->pw_dir, DEFAULT_CONFIG_NAME);
> + len= strlen(usr->pw_dir) + 1 + strlen(DEFAULT_CONFIG_NAME) + 1;
> + if ((userpath = malloc(len)) == NULL)
Small style nit, the code uses no spaces before assignment.
> diff -ur libmemcached-0.44//tests/server.c libmemcached-0.44.modified//tests/server.c
> --- libmemcached-0.44//tests/server.c 2010-08-03 08:30:54.000000000 +0200
> +++ libmemcached-0.44.modified//tests/server.c 2011-10-13 18:11:24.000000000 +0200
> @@ -117,18 +117,30 @@
> }
> }
>
> - char buffer[PATH_MAX];
> - snprintf(buffer, sizeof(buffer), PID_FILE_BASE, x);
> + char *buffer= NULL;
> + size_t len= 0;
> +
> + len= strlen(PID_FILE_BASE) + sizeof(int) - 2 + 1;
> + if ((buffer = malloc(len)) == NULL)
Likewise.
> + assert(buffer);
> + snprintf(buffer, len, PID_FILE_BASE, x);
> kill_file(buffer);
>
> if (x == 0)
> {
> - snprintf(buffer, sizeof(buffer), "%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u -m 128",
> + len= strlen("%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u -m 128") + strlen(MEMCACHED_BINARY) + 3*sizeof(int)- 4*2 + 1;
> + if ((buffer = malloc(len)) == NULL)
Likewise.
> + assert(buffer);
> + snprintf(buffer, len, "%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u -m 128",
> MEMCACHED_BINARY, x, port, port);
> }
> else
> {
> - snprintf(buffer, sizeof(buffer), "%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u",
> + len= strlen("%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u") +
> + strlen(MEMCACHED_BINARY) + 3*sizeof(int) - 4*2 + 1;
> + if ((buffer = malloc(len)) == NULL)
Likewise.
> + assert(buffer);
> + snprintf(buffer, len, "%s -d -u root -P "PID_FILE_BASE" -t 1 -p %u -U %u",
> MEMCACHED_BINARY, x, port, port);
> }
> if (libmemcached_util_ping("localhost", port, NULL))
> @@ -229,9 +248,15 @@
> {
> for (uint32_t x= 0; x < construct->count; x++)
> {
> - char file_buffer[PATH_MAX]; /* Nothing special for number */
> - snprintf(file_buffer, sizeof(file_buffer), PID_FILE_BASE, x);
> + char *file_buffer= NULL; /* Nothing special for number */
> + size_t len= 0;
> +
> + len= strlen(PID_FILE_BASE) + sizeof(int) - 2 + 1;
> + if ((file_buffer = malloc(len)) == NULL)
Likewise.
thanks,
guillem
Reply to: