target-arm queue:

* Fixes for seven minor coverity issues
 -----BEGIN PGP SIGNATURE-----
 
 iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmYBh5wZHHBldGVyLm1h
 eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3lb8D/9XDbRFB3kIHVBaDxZyE4bs
 QH8u80C08f/PzJ5SQos5D+R07xtPid1dyeiLND/RvwZUN3WAGKf9pmPUQL4aluz5
 gHMalq/+nGNam2qz+tKTI0q0otndiJrGNlOYhw2QqFJ9GUp2T9e61izgw0XeQtzF
 GKm6aE8LytH7h2H9ndIpJFQDggqkQev/uZ625hwhYxo0ND5uRqBNE7Wjy104DULo
 oEGZBhIB2CtyDiQdxgCfC8TOXVT3NAEbk6carbYdGshrMTpWNsjOHbLVcsuqUaZC
 eeRnOprsQq+YE5aAByfipGgCuoGNE5rn6ZTrDpSdfLe8LFfU/hEASnOmIjMtMbSM
 HKhKcKKzvLk/KQZZNJCbh+MKl1GsTvXMrB/DjLaVu2643MyQY7XZu3/XX3PE6Zee
 WqJC+NazfXCdHDyYqfPELkmnpeS5Tka/PCoku1VNWmnr7Qr6SYIqzbxI+zCsbDCs
 uqDfxzwN1lTKCkgUD3SVQrmrQ3u9nTLCpTqmaEd6H3+0UgpEUBpW51bMPUxO3KIk
 ouvjVJ3oDSdNMyVrEl3zDoxykU99trRYbIRALrW+rd1ghn4SE0WorAGJ96GLGYP0
 QfFtveTmDqsfKOvxHfBx6gng0aQw0GK145uXLciRaPuX51wZGbAjp/Muhs6oswtR
 j7GgfYAbVdc1QwKTqBK0tw==
 =0H37
 -----END PGP SIGNATURE-----

Merge tag 'pull-target-arm-20240325-1' of https://git.linaro.org/people/pmaydell/qemu-arm into staging

target-arm queue:
 * Fixes for seven minor coverity issues

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmYBh5wZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3lb8D/9XDbRFB3kIHVBaDxZyE4bs
# QH8u80C08f/PzJ5SQos5D+R07xtPid1dyeiLND/RvwZUN3WAGKf9pmPUQL4aluz5
# gHMalq/+nGNam2qz+tKTI0q0otndiJrGNlOYhw2QqFJ9GUp2T9e61izgw0XeQtzF
# GKm6aE8LytH7h2H9ndIpJFQDggqkQev/uZ625hwhYxo0ND5uRqBNE7Wjy104DULo
# oEGZBhIB2CtyDiQdxgCfC8TOXVT3NAEbk6carbYdGshrMTpWNsjOHbLVcsuqUaZC
# eeRnOprsQq+YE5aAByfipGgCuoGNE5rn6ZTrDpSdfLe8LFfU/hEASnOmIjMtMbSM
# HKhKcKKzvLk/KQZZNJCbh+MKl1GsTvXMrB/DjLaVu2643MyQY7XZu3/XX3PE6Zee
# WqJC+NazfXCdHDyYqfPELkmnpeS5Tka/PCoku1VNWmnr7Qr6SYIqzbxI+zCsbDCs
# uqDfxzwN1lTKCkgUD3SVQrmrQ3u9nTLCpTqmaEd6H3+0UgpEUBpW51bMPUxO3KIk
# ouvjVJ3oDSdNMyVrEl3zDoxykU99trRYbIRALrW+rd1ghn4SE0WorAGJ96GLGYP0
# QfFtveTmDqsfKOvxHfBx6gng0aQw0GK145uXLciRaPuX51wZGbAjp/Muhs6oswtR
# j7GgfYAbVdc1QwKTqBK0tw==
# =0H37
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 25 Mar 2024 14:18:04 GMT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [ultimate]
# gpg:                 aka "Peter Maydell <peter@archaic.org.uk>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20240325-1' of https://git.linaro.org/people/pmaydell/qemu-arm:
  tests/qtest/libqtest.c: Check for g_setenv() failure
  tests/unit/test-throttle: Avoid unintended integer division
  hw/nvram/mac_nvram: Report failure to write data
  hw/misc/pca9554: Correct error check bounds in get/set pin functions
  net/af-xdp.c: Don't leak sock_fds array in net_init_af_xdp()
  tests/unit/socket-helpers: Don't close(-1)
  tests/qtest/npcm7xx_emc_test: Don't leak cmd_line

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2024-03-25 14:19:32 +00:00
commit 0cf74ffedd
7 changed files with 20 additions and 11 deletions

View File

@ -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;
}

View File

@ -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));
}
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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.