[sheepdog] [PATCH]Check malloc error for collie

MORITA Kazutaka morita.kazutaka at gmail.com
Mon Feb 18 01:10:06 CET 2013


At Thu, 14 Feb 2013 23:03:57 +0800,
harryxiyou at gmail.com wrote:
>  
>  static const struct subcommand *find_subcmd(const char *cmd, const char *subcmd)
> @@ -322,7 +326,11 @@ int main(int argc, char **argv)
>  	char *p;
>  	const struct sd_option *sd_opts;
>  
> -	init_commands(&commands);
> +	ret = init_commands(&commands);
> +	if (ret < 0) {
> +		fprintf(stderr, "Failed to init commands.\n");
> +		exit(EXIT_SYSFAIL);
> +	}

Since the program exits either way, how about using xmalloc as we do
in other places?

Thanks for your contribution.

Kazutaka



More information about the sheepdog mailing list