[Devel] Re: [PATCH 1/4] Fix ckpt_write_err() check for empty string
Oren Laadan
orenl at librato.com
Wed Oct 14 15:32:16 PDT 2009
(This is the same one you posted some time ago ...)
Pulled, thanks.
Matt Helsley wrote:
> The test for empty error strings does not work because we always add 2
> to len before testing if it's 0. Fix by checking before adding 2.
>
> Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
> ---
> checkpoint/checkpoint.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/checkpoint/checkpoint.c b/checkpoint/checkpoint.c
> index eaa9105..5a76d2b 100644
> --- a/checkpoint/checkpoint.c
> +++ b/checkpoint/checkpoint.c
> @@ -258,11 +258,11 @@ int ckpt_write_err(struct ckpt_ctx *ctx, char *fmt0, char *fmt, ...)
> }
>
> str = ctx->err_string;
> - len = strlen(str + 1) + 2; /* leading and trailing '\0' */
> -
> + len = strlen(str + 1);
> if (len == 0) /* empty error string */
> return 0;
>
> + len += 2; /* leading and trailing '\0' */
> ret = ckpt_write_obj_type(ctx, NULL, 0, CKPT_HDR_ERROR);
> if (!ret)
> ret = ckpt_write_string(ctx, str, len);
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list