[sheepdog] [PATCH 1/9] add forward error correction for erasure code

Hitoshi Mitake mitake.hitoshi at gmail.com
Fri Sep 20 10:11:34 CEST 2013


This would be a great contribution!

I'd like to post some trivial comments not related to essential part
of erasure coding.

At Thu, 19 Sep 2013 18:42:45 +0800,
Liu Yuan wrote:
> +#include <stddef.h>
> +#include <stdint.h>
> +
> +#ifdef __GNUC__
> +#ifndef alloca
> +#define alloca(x) __builtin_alloca(x)
> +#endif
> +#else
> +#include <alloca.h>
> +#endif

This alloca() is only used by fec_decode() in lib/fec.c. The caller
part,
	uint8_t *m_dec = (uint8_t *)alloca(code->k * code->k);
can be replaced by this because we are using C99 style:
	uint8_t m_dec[code->k * code->k];

Let's eliminate the alloca() definition.

> +
> +/* Return the erasure code context to encode|decode */
> +static inline void *ec_init(void)
> +{
> +	return fec_new(SD_EC_D, SD_EC_DP);
> +}

Using void pointer for storing ec context should be avoided. They can
be struct fec * .

Thanks,
Hitoshi



More information about the sheepdog mailing list