Merge remote-tracking branch 'stefanha/trivial-patches' into staging
* stefanha/trivial-patches: w32: Always use standard instead of native format strings net/socket: Fix compiler warning (regression for MinGW) linux-user: Remove redundant null check and replace free by g_free qemu-timer: simplify qemu_run_timers TextConsole: saturate escape parameter in TTY_STATE_CSI curses: don't initialize curses when qemu is daemonized dtrace backend: add function to reserved words pflash_cfi01: Fix warning caused by unreachable code ioh3420: Remove unreachable code lm4549: Fix buffer overflow cadence_uart: Fix buffer overflow qemu-sockets: Fix potential memory leak qemu-ga: Remove unreachable code after g_error target-i386: Allow tsc-frequency to be larger then 2.147G
This commit is contained in:
commit
3988475b9b
@ -44,6 +44,11 @@
|
||||
/* Use gnu_printf when supported (qemu uses standard format strings). */
|
||||
# define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
|
||||
# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
|
||||
# if defined(_WIN32)
|
||||
/* Map __printf__ to __gnu_printf__ because we want standard format strings
|
||||
* even when MinGW or GLib include files use __printf__. */
|
||||
# define __printf__ __gnu_printf__
|
||||
# endif
|
||||
# endif
|
||||
#if defined(_WIN32)
|
||||
#define GCC_WEAK __attribute__((weak))
|
||||
|
@ -938,8 +938,11 @@ static void console_putchar(TextConsole *s, int ch)
|
||||
case TTY_STATE_CSI: /* handle escape sequence parameters */
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
if (s->nb_esc_params < MAX_ESC_PARAMS) {
|
||||
s->esc_params[s->nb_esc_params] =
|
||||
s->esc_params[s->nb_esc_params] * 10 + ch - '0';
|
||||
int *param = &s->esc_params[s->nb_esc_params];
|
||||
int digit = (ch - '0');
|
||||
|
||||
*param = (*param <= (INT_MAX - digit) / 10) ?
|
||||
*param * 10 + digit : INT_MAX;
|
||||
}
|
||||
} else {
|
||||
if (s->nb_esc_params < MAX_ESC_PARAMS)
|
||||
|
@ -404,7 +404,7 @@ static uint64_t uart_read(void *opaque, target_phys_addr_t offset,
|
||||
uint32_t c = 0;
|
||||
|
||||
offset >>= 2;
|
||||
if (offset > R_MAX) {
|
||||
if (offset >= R_MAX) {
|
||||
return 0;
|
||||
} else if (offset == R_TX_RX) {
|
||||
uart_read_rx_fifo(s, &c);
|
||||
|
@ -125,7 +125,6 @@ static int ioh3420_initfn(PCIDevice *d)
|
||||
rc = pcie_chassis_add_slot(s);
|
||||
if (rc < 0) {
|
||||
goto err_pcie_cap;
|
||||
return rc;
|
||||
}
|
||||
pcie_cap_root_init(d);
|
||||
rc = pcie_aer_init(d, IOH_EP_AER_OFFSET);
|
||||
|
@ -224,7 +224,7 @@ uint32_t lm4549_write_samples(lm4549_state *s, uint32_t left, uint32_t right)
|
||||
This model supports 16-bit playback.
|
||||
*/
|
||||
|
||||
if (s->buffer_level >= LM4549_BUFFER_SIZE) {
|
||||
if (s->buffer_level > LM4549_BUFFER_SIZE - 2) {
|
||||
DPRINTF("write_sample Buffer full\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
|
||||
}
|
||||
pfl->wcycle++;
|
||||
pfl->cmd = cmd;
|
||||
return;
|
||||
break;
|
||||
case 1:
|
||||
switch (pfl->cmd) {
|
||||
case 0x10: /* Single Byte Program */
|
||||
@ -376,7 +376,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
|
||||
default:
|
||||
goto error_flash;
|
||||
}
|
||||
return;
|
||||
break;
|
||||
case 2:
|
||||
switch (pfl->cmd) {
|
||||
case 0xe8: /* Block write */
|
||||
@ -407,7 +407,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
|
||||
default:
|
||||
goto error_flash;
|
||||
}
|
||||
return;
|
||||
break;
|
||||
case 3: /* Confirm mode */
|
||||
switch (pfl->cmd) {
|
||||
case 0xe8: /* Block write */
|
||||
@ -423,7 +423,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
|
||||
default:
|
||||
goto error_flash;
|
||||
}
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
/* Should never happen */
|
||||
DPRINTF("%s: invalid write state\n", __func__);
|
||||
|
@ -3628,9 +3628,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
|
||||
unlock_user(argptr, arg, target_size);
|
||||
}
|
||||
out:
|
||||
if (big_buf) {
|
||||
free(big_buf);
|
||||
}
|
||||
g_free(big_buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf,
|
||||
ssize_t ret;
|
||||
|
||||
do {
|
||||
ret = sendto(s->fd, buf, size, 0,
|
||||
ret = qemu_sendto(s->fd, buf, size, 0,
|
||||
(struct sockaddr *)&s->dgram_dst,
|
||||
sizeof(s->dgram_dst));
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
|
@ -360,3 +360,8 @@ int qemu_create_pidfile(const char *filename)
|
||||
/* keep pidfile open & locked forever */
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_daemonized(void)
|
||||
{
|
||||
return daemonize;
|
||||
}
|
||||
|
@ -223,9 +223,14 @@ int qemu_pipe(int pipefd[2]);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* MinGW needs a type cast for the 'buf' argument. */
|
||||
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
|
||||
#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
|
||||
sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
|
||||
#else
|
||||
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
|
||||
#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
|
||||
sendto(sockfd, buf, len, flags, destaddr, addrlen)
|
||||
#endif
|
||||
|
||||
/* Error handling. */
|
||||
|
@ -114,12 +114,10 @@ static gboolean register_signal_handlers(void)
|
||||
ret = sigaction(SIGINT, &sigact, NULL);
|
||||
if (ret == -1) {
|
||||
g_error("error configuring signal handler: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
ret = sigaction(SIGTERM, &sigact, NULL);
|
||||
if (ret == -1) {
|
||||
g_error("error configuring signal handler: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -46,4 +46,6 @@ typedef struct timeval qemu_timeval;
|
||||
typedef struct timespec qemu_timespec;
|
||||
int qemu_utimens(const char *path, const qemu_timespec *times);
|
||||
|
||||
bool is_daemonized(void);
|
||||
|
||||
#endif
|
||||
|
@ -92,4 +92,9 @@ typedef struct {
|
||||
} qemu_timeval;
|
||||
int qemu_gettimeofday(qemu_timeval *tp);
|
||||
|
||||
static inline bool is_daemonized(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -353,7 +353,7 @@ int inet_dgram_opts(QemuOpts *opts)
|
||||
if (0 != (rc = getaddrinfo(addr, port, &ai, &local))) {
|
||||
fprintf(stderr,"getaddrinfo(%s,%s): %s\n", addr, port,
|
||||
gai_strerror(rc));
|
||||
return -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* create socket */
|
||||
|
@ -372,21 +372,20 @@ bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time)
|
||||
|
||||
void qemu_run_timers(QEMUClock *clock)
|
||||
{
|
||||
QEMUTimer **ptimer_head, *ts;
|
||||
QEMUTimer *ts;
|
||||
int64_t current_time;
|
||||
|
||||
if (!clock->enabled)
|
||||
return;
|
||||
|
||||
current_time = qemu_get_clock_ns(clock);
|
||||
ptimer_head = &clock->active_timers;
|
||||
for(;;) {
|
||||
ts = *ptimer_head;
|
||||
ts = clock->active_timers;
|
||||
if (!qemu_timer_expired_ns(ts, current_time)) {
|
||||
break;
|
||||
}
|
||||
/* remove timer from the list before calling the callback */
|
||||
*ptimer_head = ts->next;
|
||||
clock->active_timers = ts->next;
|
||||
ts->next = NULL;
|
||||
|
||||
/* run the callback (the timer list can be modified) */
|
||||
|
@ -87,7 +87,7 @@ def stap(events):
|
||||
if len(e.args) > 0:
|
||||
for name in e.args.names():
|
||||
# Append underscore to reserved keywords
|
||||
if name in ('limit', 'in', 'next', 'self'):
|
||||
if name in ('limit', 'in', 'next', 'self', 'function'):
|
||||
name += '_'
|
||||
out(' %s = $arg%d;' % (name, i))
|
||||
i += 1
|
||||
|
@ -1064,7 +1064,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
|
||||
{
|
||||
X86CPU *cpu = X86_CPU(obj);
|
||||
const int64_t min = 0;
|
||||
const int64_t max = INT_MAX;
|
||||
const int64_t max = INT64_MAX;
|
||||
int64_t value;
|
||||
|
||||
visit_type_int(v, &value, name, errp);
|
||||
|
Loading…
Reference in New Issue
Block a user