On Mon, Apr 14, 2025 at 04:12:13PM -0400, Stefan Hajnoczi wrote: > Populate the pdiscard_alignment block limit so the block layer is able > align discard requests correctly. > > Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> > --- > block/file-posix.c | 67 +++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 66 insertions(+), 1 deletion(-) >
> +static int get_sysfs_u32_val(struct stat *st, const char *attribute, > + uint32_t *u32) > +{ > + g_autofree char *str = NULL; > + const char *end; > + unsigned int val; > + int ret; > + > + ret = get_sysfs_str_val(st, attribute, &str); > + if (ret < 0) { > + return ret; > + } > + > + /* The file is ended with '\n', pass 'end' to accept that. */ > + ret = qemu_strtoui(str, &end, 10, &val); > + if (ret == 0 && end && *end == '\0') { This doesn't match the comment. If we expect the file contents to end in \n, then this should be checking *end == '\n', not '\0'. > + *u32 = val; > + } > + return ret; > +} > #endif > -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org