correct uninitialized value (offset)

This commit is contained in:
Laurent Vivier 2007-10-21 01:26:48 +00:00
parent cf28f647c7
commit a844b4c51a

View File

@ -14,36 +14,40 @@
int8_t* emile_second_get_configuration(int fd) int8_t* emile_second_get_configuration(int fd)
{ {
int8_t *conf = NULL; int8_t *conf;
emile_l2_header_t header; emile_l2_header_t header;
int ret; int ret;
int size; int size;
off_t offset;
memset(&header, 0, sizeof(header)); memset(&header, 0, sizeof(header));
ret = read(fd, &header, sizeof(header)); ret = read(fd, &header, sizeof(header));
if (!EMILE_COMPAT(EMILE_06_SIGNATURE, read_long(&header.signature))) if (!EMILE_COMPAT(EMILE_06_SIGNATURE, read_long(&header.signature)))
{ {
off_t offset;
offset = lseek(fd, FIRST_LEVEL_SIZE, SEEK_SET); offset = lseek(fd, FIRST_LEVEL_SIZE, SEEK_SET);
ret = read(fd, &header, sizeof(header)); ret = read(fd, &header, sizeof(header));
if (!EMILE_COMPAT(EMILE_06_SIGNATURE, read_long(&header.signature))) if (!EMILE_COMPAT(EMILE_06_SIGNATURE, read_long(&header.signature)))
goto exit; {
lseek(fd, offset, SEEK_SET);
return conf;
}
} }
if (ret != sizeof(header)) if (ret != sizeof(header))
goto exit; return NULL;
size = read_short(&header.conf_size); size = read_short(&header.conf_size);
conf = (int8_t*)malloc(size); conf = (int8_t*)malloc(size);
if (conf == NULL) if (conf == NULL)
goto exit; return NULL;
ret = read(fd, conf, size); ret = read(fd, conf, size);
if (ret != size) if (ret != size)
{
free(conf);
return NULL; return NULL;
}
exit:
lseek(fd, offset, SEEK_SET);
return conf; return conf;
} }