Skip to content

Commit

Permalink
env: mcc: fix compilation error with ENV_IS_EMBEDDED
Browse files Browse the repository at this point in the history
When ENV_IS_EMBEDDED is enabled, ret is not defined but is used as a
return value in env_mmc_load().
This patch correct this issue and simplify the existing code, test only
one time #if defined(ENV_IS_EMBEDDED) and not in the function.

Signed-off-by: Patrick Delaunay <[email protected]>
Reviewed-by: Patrice Chotard <[email protected]>
  • Loading branch information
patrickdelaunay authored and trini committed Jan 10, 2023
1 parent 46c9016 commit 8566050
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions env/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,14 @@ static inline int read_env(struct mmc *mmc, unsigned long size,
return (n == blk_cnt) ? 0 : -1;
}

#if defined(CONFIG_SYS_REDUNDAND_ENVIRONMENT)
#if defined(ENV_IS_EMBEDDED)
static int env_mmc_load(void)
{
return 0;
}
#elif defined(CONFIG_SYS_REDUNDAND_ENVIRONMENT)
static int env_mmc_load(void)
{
#if !defined(ENV_IS_EMBEDDED)
struct mmc *mmc;
u32 offset1, offset2;
int read1_fail = 0, read2_fail = 0;
Expand Down Expand Up @@ -408,13 +412,11 @@ static int env_mmc_load(void)
if (ret)
env_set_default(errmsg, 0);

#endif
return ret;
}
#else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
static int env_mmc_load(void)
{
#if !defined(ENV_IS_EMBEDDED)
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
struct mmc *mmc;
u32 offset;
Expand Down Expand Up @@ -453,7 +455,7 @@ static int env_mmc_load(void)
err:
if (ret)
env_set_default(errmsg, 0);
#endif

return ret;
}
#endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
Expand Down

0 comments on commit 8566050

Please sign in to comment.