Silence gcc 4.4.1 compiler warnings

svn: r16411
This commit is contained in:
Kevin Tew 2009-10-22 17:17:32 +00:00
parent aa7a99112e
commit 2955ff1b0e
6 changed files with 61 additions and 25 deletions

View File

@ -10,6 +10,7 @@
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <stdio.h>
/* The config string after : is replaced with ! followed by a sequence /* The config string after : is replaced with ! followed by a sequence
of little-endian 4-byte ints: of little-endian 4-byte ints:
@ -95,9 +96,9 @@ static int is_x_flag(char *s)
return 0; return 0;
} }
static void write_str(int fd, char *s) static int write_str(int fd, char *s)
{ {
write(fd, s, strlen(s)); return write(fd, s, strlen(s));
} }
#if 0 #if 0
@ -330,7 +331,13 @@ int main(int argc, char **argv)
fd = open(me, O_RDONLY, 0); fd = open(me, O_RDONLY, 0);
lseek(fd, prog_end, SEEK_SET); lseek(fd, prog_end, SEEK_SET);
read(fd, data, end - prog_end); {
int expected_length = end - prog_end;
if (expected_length != read(fd, data, expected_length)) {
printf("read failed to read all %i bytes from file %s\n", expected_length, me);
abort();
}
}
close(fd); close(fd);
exe_path = data; exe_path = data;

View File

@ -5836,7 +5836,8 @@ void scheme_gmp_tls_snapshot(long *s, long *save)
void scheme_gmp_tls_restore_snapshot(long *s, void *data, long *save, int do_free) void scheme_gmp_tls_restore_snapshot(long *s, void *data, long *save, int do_free)
{ {
long other[6]; /* silence gcc "may be used uninitialized in this function" warnings */
long other[6] = {0,0,0,0,0,0};
void *other_data; void *other_data;
if (do_free == 2) { if (do_free == 2) {

View File

@ -1676,23 +1676,41 @@ static Scheme_Object *bytes_to_integer (int argc, Scheme_Object *argv[])
switch(slen) { switch(slen) {
case 2: case 2:
if (sgned) if (sgned) {
return scheme_make_integer(((short *)str)[0]); short val;
else memcpy(&val, str, sizeof(short));
return scheme_make_integer(((unsigned short *)str)[0]); return scheme_make_integer(val);
}
else {
unsigned short val;
memcpy(&val, str, sizeof(unsigned short));
return scheme_make_integer(val);
}
break; break;
case 4: case 4:
if (sgned) if (sgned) {
return scheme_make_integer_value(((int *)str)[0]); int val;
else memcpy(&val, str, sizeof(int));
return scheme_make_integer_value_from_unsigned(((unsigned int *)str)[0]); return scheme_make_integer_value(val);
}
else {
unsigned int val;
memcpy(&val, str, sizeof(unsigned int));
return scheme_make_integer_value_from_unsigned(val);
}
break; break;
default: default:
#ifdef SIXTY_FOUR_BIT_INTEGERS #ifdef SIXTY_FOUR_BIT_INTEGERS
if (sgned) if (sgned) {
return scheme_make_integer_value(((long *)str)[0]); long val;
else memcpy(&val, str, sizeof(long));
return scheme_make_integer_value_from_unsigned(((unsigned long *)str)[0]); return scheme_make_integer_value(val);
}
else {
unsigned long val;
memcpy(&val, str, sizeof(unsigned long));
return scheme_make_integer_value_from_unsigned(val);
}
break; break;
#else #else
# ifndef NO_LONG_LONG_TYPE # ifndef NO_LONG_LONG_TYPE
@ -1875,19 +1893,21 @@ static Scheme_Object *integer_to_bytes(int argc, Scheme_Object *argv[])
case 2: case 2:
{ {
if (sgned) { if (sgned) {
*(unsigned short *)str = (unsigned short)(val); unsigned short value = val;
memcpy(str, &value, sizeof(unsigned short));
} else { } else {
*(short *)str = (short)(val); short value = val;
memcpy(str, &value, sizeof(short));
} }
} }
break; break;
case 4: case 4:
if (sgned) { if (sgned) {
unsigned int sv = val; unsigned int value = val;
*(unsigned int *)str = sv; memcpy(str, &value, sizeof(unsigned int));
} else { } else {
int sv = val; int value = val;
*(int *)str = sv; memcpy(str, &value, sizeof(int));
} }
break; break;
default: default:

View File

@ -8350,8 +8350,11 @@ static void default_sleep(float v, void *fds)
#if defined(FILES_HAVE_FDS) #if defined(FILES_HAVE_FDS)
/* Clear external event flag */ /* Clear external event flag */
if (external_event_fd) { if (external_event_fd) {
int rc;
char buf[10]; char buf[10];
read(external_event_fd, buf, 10); do {
rc = read(external_event_fd, buf, 10);
} while ((rc == -1) && errno == EINTR);
} }
#endif #endif
} }

View File

@ -362,6 +362,11 @@ XFORM_NONGCING static void WRAP_POS_SET_FIRST(Wrap_Pos *w)
w->a = a; w->a = a;
} }
} }
/* silence gcc "may be used uninitialized in this function" warnings */
else {
w->a = NULL;
w->is_limb = 0;
}
} }
XFORM_NONGCING static MZ_INLINE void DO_WRAP_POS_INC(Wrap_Pos *w) XFORM_NONGCING static MZ_INLINE void DO_WRAP_POS_INC(Wrap_Pos *w)

View File

@ -215,10 +215,10 @@ do { \
# define dprintf(format...) # define dprintf(format...)
#endif #endif
static ALWAYS_INLINE void static ALWAYS_INLINE int
print_error (const char *string) print_error (const char *string)
{ {
write (2, string, strlen (string)); return write (2, string, strlen (string));
} }
#define mi_init UNWI_ARCH_OBJ(mi_init) #define mi_init UNWI_ARCH_OBJ(mi_init)