mirror of
https://github.com/gwenhael-le-moine/x49gp.git
synced 2024-12-25 21:58:49 +01:00
[3298] Compile warnings fixed
This commit is contained in:
parent
c3ed313cf7
commit
cb4ed1a375
4 changed files with 44 additions and 14 deletions
2
Makefile
2
Makefile
|
@ -82,7 +82,7 @@ CC += $(shell if [ "`uname -m`" = "sparc64" -o "`uname -m`" = "sun4u" ]; then ec
|
|||
|
||||
COCOA_LIBS=$(shell if [ "`uname -s`" = "Darwin" ]; then echo "-F/System/Library/Frameworks -framework Cocoa -framework IOKit"; fi)
|
||||
|
||||
CFLAGS = -O2 -Wall -Werror -Wno-unused-result $(DEBUG) $(INCLUDES) $(DEFINES)
|
||||
CFLAGS = -O2 -Wall -Werror -D_FORTIFY_SOURCE=1 $(DEBUG) $(INCLUDES) $(DEFINES)
|
||||
LDFLAGS = $(DEBUG) $(X49GP_LDFLAGS) $(GDB_LDFLAGS)
|
||||
LDLIBS = $(X49GP_LIBS) $(GDB_LIBS) $(COCOA_LIBS)
|
||||
|
||||
|
|
25
block-qcow.c
25
block-qcow.c
|
@ -436,6 +436,7 @@ static int qcow_create(const char *filename, int64_t total_size,
|
|||
int fd, header_size, backing_filename_len, l1_size, i, shift;
|
||||
QCowHeader header;
|
||||
uint64_t tmp;
|
||||
int ret;
|
||||
|
||||
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
|
||||
if (fd < 0)
|
||||
|
@ -471,17 +472,33 @@ static int qcow_create(const char *filename, int64_t total_size,
|
|||
}
|
||||
|
||||
/* write all the data */
|
||||
write(fd, &header, sizeof(header));
|
||||
ret = write(fd, &header, sizeof(header));
|
||||
if (ret != sizeof(header)) {
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (backing_file) {
|
||||
write(fd, backing_file, backing_filename_len);
|
||||
ret = write(fd, backing_file, backing_filename_len);
|
||||
if (ret != backing_filename_len) {
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
lseek(fd, header_size, SEEK_SET);
|
||||
tmp = 0;
|
||||
for(i = 0;i < l1_size; i++) {
|
||||
write(fd, &tmp, sizeof(tmp));
|
||||
ret = write(fd, &tmp, sizeof(tmp));
|
||||
if (ret != sizeof(tmp)) {
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
exit:
|
||||
close(fd);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int qcow_make_empty(BlockDriverState *bs)
|
||||
|
|
17
block-raw.c
17
block-raw.c
|
@ -227,17 +227,24 @@ static int raw_create(const char *filename, int64_t total_size,
|
|||
const char *backing_file, int flags)
|
||||
{
|
||||
int fd;
|
||||
int result = 0;
|
||||
|
||||
if (flags || backing_file)
|
||||
return -ENOTSUP;
|
||||
|
||||
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
|
||||
0644);
|
||||
if (fd < 0)
|
||||
return -EIO;
|
||||
ftruncate(fd, total_size * 512);
|
||||
close(fd);
|
||||
return 0;
|
||||
if (fd < 0) {
|
||||
result=-errno;
|
||||
} else {
|
||||
if (ftruncate(fd, total_size * 512)) {
|
||||
result=-errno;
|
||||
}
|
||||
if (close(fd) != 0) {
|
||||
result=-errno;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void raw_flush(BlockDriverState *bs)
|
||||
|
|
|
@ -888,11 +888,14 @@ static int init_directories(BDRVVVFATState* s,
|
|||
stat(dirname, &st);
|
||||
entry = array_get_next(&(s->directory));
|
||||
entry->attributes = 0x08; /* archive | volume label */
|
||||
memset(entry->name, ' ', 11);
|
||||
memset(entry->name, ' ', 8);
|
||||
memset(entry->extension, ' ', 3);
|
||||
namelen = strlen(VOLUME_LABEL);
|
||||
if (namelen > 11)
|
||||
namelen = 11;
|
||||
memcpy(entry->name, VOLUME_LABEL, namelen);
|
||||
memcpy(entry->name, VOLUME_LABEL, namelen > 8 ? 8 : namelen);
|
||||
if (namelen > 8)
|
||||
memcpy(entry->extension, VOLUME_LABEL+8, namelen-8);
|
||||
entry->reserved[0] = entry->reserved[1] = 0;
|
||||
entry->ctime = fat_datetime(st.st_ctime, 1);
|
||||
entry->cdate = fat_datetime(st.st_ctime, 0);
|
||||
|
@ -2353,8 +2356,11 @@ static int commit_one_file(BDRVVVFATState* s,
|
|||
c = c1;
|
||||
}
|
||||
|
||||
ftruncate(fd, size);
|
||||
close(fd);
|
||||
if (ftruncate(fd, size)) {
|
||||
perror("ftruncate()");
|
||||
close(fd);
|
||||
return -4;
|
||||
}
|
||||
|
||||
return commit_mappings(s, first_cluster, dir_index);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue