aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/misc/pca9554.c4
-rw-r--r--hw/nvram/mac_nvram.c6
-rw-r--r--net/af-xdp.c3
-rw-r--r--tests/qtest/libqtest.c6
-rw-r--r--tests/qtest/npcm7xx_emc-test.c4
-rw-r--r--tests/unit/socket-helpers.c4
-rw-r--r--tests/unit/test-throttle.c4
7 files changed, 20 insertions, 11 deletions
diff --git a/hw/misc/pca9554.c b/hw/misc/pca9554.c
index 778b32e..5e31696 100644
--- a/hw/misc/pca9554.c
+++ b/hw/misc/pca9554.c
@@ -160,7 +160,7 @@ static void pca9554_get_pin(Object *obj, Visitor *v, const char *name,
error_setg(errp, "%s: error reading %s", __func__, name);
return;
}
- if (pin < 0 || pin > PCA9554_PIN_COUNT) {
+ if (pin < 0 || pin >= PCA9554_PIN_COUNT) {
error_setg(errp, "%s invalid pin %s", __func__, name);
return;
}
@@ -187,7 +187,7 @@ static void pca9554_set_pin(Object *obj, Visitor *v, const char *name,
error_setg(errp, "%s: error reading %s", __func__, name);
return;
}
- if (pin < 0 || pin > PCA9554_PIN_COUNT) {
+ if (pin < 0 || pin >= PCA9554_PIN_COUNT) {
error_setg(errp, "%s invalid pin %s", __func__, name);
return;
}
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index 5f9d16f..fe9df9f 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -33,6 +33,7 @@
#include "migration/vmstate.h"
#include "qemu/cutils.h"
#include "qemu/module.h"
+#include "qemu/error-report.h"
#include "trace.h"
#include <zlib.h>
@@ -48,7 +49,10 @@ static void macio_nvram_writeb(void *opaque, hwaddr addr,
trace_macio_nvram_write(addr, value);
s->data[addr] = value;
if (s->blk) {
- blk_pwrite(s->blk, addr, 1, &s->data[addr], 0);
+ if (blk_pwrite(s->blk, addr, 1, &s->data[addr], 0) < 0) {
+ error_report("%s: write of NVRAM data to backing store failed",
+ blk_name(s->blk));
+ }
}
}
diff --git a/net/af-xdp.c b/net/af-xdp.c
index 38e6007..01c5fb9 100644
--- a/net/af-xdp.c
+++ b/net/af-xdp.c
@@ -446,7 +446,7 @@ int net_init_af_xdp(const Netdev *netdev,
NetClientState *nc, *nc0 = NULL;
unsigned int ifindex;
uint32_t prog_id = 0;
- int *sock_fds = NULL;
+ g_autofree int *sock_fds = NULL;
int64_t i, queues;
Error *err = NULL;
AFXDPState *s;
@@ -516,7 +516,6 @@ int net_init_af_xdp(const Netdev *netdev,
return 0;
err:
- g_free(sock_fds);
if (nc0) {
qemu_del_net_client(nc0);
}
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index f33a210..d8f80d3 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -1814,7 +1814,11 @@ QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch,
* way, qtest_get_arch works for inproc qtest.
*/
gchar *bin_path = g_strconcat("/qemu-system-", arch, NULL);
- g_setenv("QTEST_QEMU_BINARY", bin_path, 0);
+ if (!g_setenv("QTEST_QEMU_BINARY", bin_path, 0)) {
+ fprintf(stderr,
+ "Could not set environment variable QTEST_QEMU_BINARY\n");
+ exit(1);
+ }
g_free(bin_path);
return qts;
diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c
index 63f6cad..2e1a1a6 100644
--- a/tests/qtest/npcm7xx_emc-test.c
+++ b/tests/qtest/npcm7xx_emc-test.c
@@ -789,7 +789,7 @@ static void emc_test_ptle(QTestState *qts, const EMCModule *mod, int fd)
static void test_tx(gconstpointer test_data)
{
const TestData *td = test_data;
- GString *cmd_line = g_string_new("-machine quanta-gsj");
+ g_autoptr(GString) cmd_line = g_string_new("-machine quanta-gsj");
int *test_sockets = packet_test_init(emc_module_index(td->module),
cmd_line);
QTestState *qts = qtest_init(cmd_line->str);
@@ -814,7 +814,7 @@ static void test_tx(gconstpointer test_data)
static void test_rx(gconstpointer test_data)
{
const TestData *td = test_data;
- GString *cmd_line = g_string_new("-machine quanta-gsj");
+ g_autoptr(GString) cmd_line = g_string_new("-machine quanta-gsj");
int *test_sockets = packet_test_init(emc_module_index(td->module),
cmd_line);
QTestState *qts = qtest_init(cmd_line->str);
diff --git a/tests/unit/socket-helpers.c b/tests/unit/socket-helpers.c
index 6de27ba..f3439cc 100644
--- a/tests/unit/socket-helpers.c
+++ b/tests/unit/socket-helpers.c
@@ -160,7 +160,6 @@ void socket_check_afunix_support(bool *has_afunix)
int fd;
fd = socket(PF_UNIX, SOCK_STREAM, 0);
- close(fd);
#ifdef _WIN32
*has_afunix = (fd != (int)INVALID_SOCKET);
@@ -168,5 +167,8 @@ void socket_check_afunix_support(bool *has_afunix)
*has_afunix = (fd >= 0);
#endif
+ if (*has_afunix) {
+ close(fd);
+ }
return;
}
diff --git a/tests/unit/test-throttle.c b/tests/unit/test-throttle.c
index 2146cfa..24032a0 100644
--- a/tests/unit/test-throttle.c
+++ b/tests/unit/test-throttle.c
@@ -127,13 +127,13 @@ static void test_compute_wait(void)
bkt.avg = 10;
bkt.max = 200;
for (i = 0; i < 22; i++) {
- double units = bkt.max / 10;
+ double units = bkt.max / 10.0;
bkt.level += units;
bkt.burst_level += units;
throttle_leak_bucket(&bkt, NANOSECONDS_PER_SECOND / 10);
wait = throttle_compute_wait(&bkt);
g_assert(double_cmp(bkt.burst_level, 0));
- g_assert(double_cmp(bkt.level, (i + 1) * (bkt.max - bkt.avg) / 10));
+ g_assert(double_cmp(bkt.level, (i + 1) * (bkt.max - bkt.avg) / 10.0));
/* We can do bursts for the 2 seconds we have configured in
* burst_length. We have 100 extra milliseconds of burst
* because bkt.level has been leaking during this time.