Message ID | 20240930081458.1926382-23-marcandre.lureau@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | -Werror=maybe-uninitialized fixes | expand |
On Monday, September 30, 2024 10:14:57 AM CEST Marc-André Lureau wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > ../fsdev/9p-iov-marshal.c:93:23: error: ‘val’ may be used uninitialized [-Werror=maybe-uninitialized] > and similar > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > fsdev/9p-iov-marshal.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fsdev/9p-iov-marshal.c b/fsdev/9p-iov-marshal.c > index a1c9beddd2..75fb87a490 100644 > --- a/fsdev/9p-iov-marshal.c > +++ b/fsdev/9p-iov-marshal.c > @@ -84,7 +84,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset, > break; > } > case 'w': { > - uint16_t val, *valp; > + uint16_t val = 0, *valp; > valp = va_arg(ap, uint16_t *); > copied = v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val)); Another option would be inserting here: if (copied <= 0) break; Same below. But I leave it up to you: Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com> /Christian > if (bswap) { > @@ -95,7 +95,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset, > break; > } > case 'd': { > - uint32_t val, *valp; > + uint32_t val = 0, *valp; > valp = va_arg(ap, uint32_t *); > copied = v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val)); > if (bswap) { > @@ -106,7 +106,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset, > break; > } > case 'q': { > - uint64_t val, *valp; > + uint64_t val = 0, *valp; > valp = va_arg(ap, uint64_t *); > copied = v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val)); > if (bswap) { >
Hi Christian On Mon, Sep 30, 2024 at 1:27 PM Christian Schoenebeck via < qemu-devel@nongnu.org> wrote: > On Monday, September 30, 2024 10:14:57 AM CEST Marc-André Lureau wrote: > > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > > > ../fsdev/9p-iov-marshal.c:93:23: error: ‘val’ may be used uninitialized > [-Werror=maybe-uninitialized] > > and similar > > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > > --- > > fsdev/9p-iov-marshal.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/fsdev/9p-iov-marshal.c b/fsdev/9p-iov-marshal.c > > index a1c9beddd2..75fb87a490 100644 > > --- a/fsdev/9p-iov-marshal.c > > +++ b/fsdev/9p-iov-marshal.c > > @@ -84,7 +84,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int > out_num, size_t offset, > > break; > > } > > case 'w': { > > - uint16_t val, *valp; > > + uint16_t val = 0, *valp; > > valp = va_arg(ap, uint16_t *); > > copied = v9fs_unpack(&val, out_sg, out_num, offset, > sizeof(val)); > > Another option would be inserting here: > > if (copied <= 0) break; > > Same below. But I leave it up to you: > > Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com> > > Ok, done thanks > /Christian > > > if (bswap) { > > @@ -95,7 +95,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int > out_num, size_t offset, > > break; > > } > > case 'd': { > > - uint32_t val, *valp; > > + uint32_t val = 0, *valp; > > valp = va_arg(ap, uint32_t *); > > copied = v9fs_unpack(&val, out_sg, out_num, offset, > sizeof(val)); > > if (bswap) { > > @@ -106,7 +106,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, > int out_num, size_t offset, > > break; > > } > > case 'q': { > > - uint64_t val, *valp; > > + uint64_t val = 0, *valp; > > valp = va_arg(ap, uint64_t *); > > copied = v9fs_unpack(&val, out_sg, out_num, offset, > sizeof(val)); > > if (bswap) { > > > > > >
diff --git a/fsdev/9p-iov-marshal.c b/fsdev/9p-iov-marshal.c index a1c9beddd2..75fb87a490 100644 --- a/fsdev/9p-iov-marshal.c +++ b/fsdev/9p-iov-marshal.c @@ -84,7 +84,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset, break; } case 'w': { - uint16_t val, *valp; + uint16_t val = 0, *valp; valp = va_arg(ap, uint16_t *); copied = v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val)); if (bswap) { @@ -95,7 +95,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset, break; } case 'd': { - uint32_t val, *valp; + uint32_t val = 0, *valp; valp = va_arg(ap, uint32_t *); copied = v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val)); if (bswap) { @@ -106,7 +106,7 @@ ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset, break; } case 'q': { - uint64_t val, *valp; + uint64_t val = 0, *valp; valp = va_arg(ap, uint64_t *); copied = v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val)); if (bswap) {