* [PATCH] 9pfs: move qemu_dirent_dup() from osdep -> 9p-util
@ 2022-03-01 20:33 Christian Schoenebeck
2022-03-01 21:59 ` Peter Maydell
2022-03-03 12:21 ` Christian Schoenebeck
0 siblings, 2 replies; 5+ messages in thread
From: Christian Schoenebeck @ 2022-03-01 20:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Greg Kurz, Peter Maydell
Function qemu_dirent_dup() is currently only used by 9pfs server, so move
it from project global header osdep.h to 9pfs specific header 9p-util.h.
Link: https://lore.kernel.org/qemu-devel/CAFEAcA_=HAUNomKD2wurSVaAHa5mrk22A1oHKLWUDjk7v6Khmg@mail.gmail.com/
Based-on: <20220227223522.91937-12-wwcohen@gmail.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
hw/9pfs/9p-util.h | 30 ++++++++++++++++++++++++++++++
include/qemu/osdep.h | 13 -------------
util/osdep.c | 21 ---------------------
3 files changed, 30 insertions(+), 34 deletions(-)
diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h
index 1f74d37558..8b92614e6c 100644
--- a/hw/9pfs/9p-util.h
+++ b/hw/9pfs/9p-util.h
@@ -112,6 +112,36 @@ static inline off_t qemu_dirent_off(struct dirent *dent)
#endif
}
+/**
+ * Duplicate directory entry @dent.
+ *
+ * It is highly recommended to use this function instead of open coding
+ * duplication of @c dirent objects, because the actual @c struct @c dirent
+ * size may be bigger or shorter than @c sizeof(struct dirent) and correct
+ * handling is platform specific (see gitlab issue #841).
+ *
+ * @dent - original directory entry to be duplicated
+ * @returns duplicated directory entry which should be freed with g_free()
+ */
+static inline struct dirent *qemu_dirent_dup(struct dirent *dent)
+{
+ size_t sz = 0;
+#if defined _DIRENT_HAVE_D_RECLEN
+ /* Avoid use of strlen() if platform supports d_reclen. */
+ sz = dent->d_reclen;
+#endif
+ /*
+ * Test sz for zero even if d_reclen is available
+ * because some drivers may set d_reclen to zero.
+ */
+ if (sz == 0) {
+ /* Fallback to the most portable way. */
+ sz = offsetof(struct dirent, d_name) +
+ strlen(dent->d_name) + 1;
+ }
+ return g_memdup(dent, sz);
+}
+
/*
* As long as mknodat is not available on macOS, this workaround
* using pthread_fchdir_np is needed. qemu_mknodat is defined in
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 7bcce3bceb..650ba1aa50 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -673,19 +673,6 @@ static inline int platform_does_not_support_system(const char *command)
}
#endif /* !HAVE_SYSTEM_FUNCTION */
-/**
- * Duplicate directory entry @dent.
- *
- * It is highly recommended to use this function instead of open coding
- * duplication of @c dirent objects, because the actual @c struct @c dirent
- * size may be bigger or shorter than @c sizeof(struct dirent) and correct
- * handling is platform specific (see gitlab issue #841).
- *
- * @dent - original directory entry to be duplicated
- * @returns duplicated directory entry which should be freed with g_free()
- */
-struct dirent *qemu_dirent_dup(struct dirent *dent);
-
#ifdef __cplusplus
}
#endif
diff --git a/util/osdep.c b/util/osdep.c
index 723cdcb004..7c4deda6fe 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -33,7 +33,6 @@
extern int madvise(char *, size_t, int);
#endif
-#include <dirent.h>
#include "qemu-common.h"
#include "qemu/cutils.h"
#include "qemu/sockets.h"
@@ -619,23 +618,3 @@ writev(int fd, const struct iovec *iov, int iov_cnt)
return readv_writev(fd, iov, iov_cnt, true);
}
#endif
-
-struct dirent *
-qemu_dirent_dup(struct dirent *dent)
-{
- size_t sz = 0;
-#if defined _DIRENT_HAVE_D_RECLEN
- /* Avoid use of strlen() if platform supports d_reclen. */
- sz = dent->d_reclen;
-#endif
- /*
- * Test sz for zero even if d_reclen is available
- * because some drivers may set d_reclen to zero.
- */
- if (sz == 0) {
- /* Fallback to the most portable way. */
- sz = offsetof(struct dirent, d_name) +
- strlen(dent->d_name) + 1;
- }
- return g_memdup(dent, sz);
-}
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] 9pfs: move qemu_dirent_dup() from osdep -> 9p-util
2022-03-01 20:33 [PATCH] 9pfs: move qemu_dirent_dup() from osdep -> 9p-util Christian Schoenebeck
@ 2022-03-01 21:59 ` Peter Maydell
2022-03-02 14:16 ` Christian Schoenebeck
2022-03-03 12:21 ` Christian Schoenebeck
1 sibling, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2022-03-01 21:59 UTC (permalink / raw)
To: Christian Schoenebeck; +Cc: qemu-devel, Greg Kurz
On Tue, 1 Mar 2022 at 20:47, Christian Schoenebeck
<qemu_oss@crudebyte.com> wrote:
>
> Function qemu_dirent_dup() is currently only used by 9pfs server, so move
> it from project global header osdep.h to 9pfs specific header 9p-util.h.
>
> Link: https://lore.kernel.org/qemu-devel/CAFEAcA_=HAUNomKD2wurSVaAHa5mrk22A1oHKLWUDjk7v6Khmg@mail.gmail.com/
> Based-on: <20220227223522.91937-12-wwcohen@gmail.com>
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
> hw/9pfs/9p-util.h | 30 ++++++++++++++++++++++++++++++
> include/qemu/osdep.h | 13 -------------
> util/osdep.c | 21 ---------------------
> 3 files changed, 30 insertions(+), 34 deletions(-)
>
> diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h
> index 1f74d37558..8b92614e6c 100644
> --- a/hw/9pfs/9p-util.h
> +++ b/hw/9pfs/9p-util.h
> @@ -112,6 +112,36 @@ static inline off_t qemu_dirent_off(struct dirent *dent)
> #endif
> }
>
> +/**
> + * Duplicate directory entry @dent.
> + *
> + * It is highly recommended to use this function instead of open coding
> + * duplication of @c dirent objects, because the actual @c struct @c dirent
> + * size may be bigger or shorter than @c sizeof(struct dirent) and correct
> + * handling is platform specific (see gitlab issue #841).
> + *
> + * @dent - original directory entry to be duplicated
> + * @returns duplicated directory entry which should be freed with g_free()
> + */
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
since it's just code movement, but those "@c"s look a bit weird:
are they really valid kerneldoc comment markup?
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] 9pfs: move qemu_dirent_dup() from osdep -> 9p-util
2022-03-01 21:59 ` Peter Maydell
@ 2022-03-02 14:16 ` Christian Schoenebeck
2022-03-02 16:59 ` Peter Maydell
0 siblings, 1 reply; 5+ messages in thread
From: Christian Schoenebeck @ 2022-03-02 14:16 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Greg Kurz
On Dienstag, 1. März 2022 22:59:43 CET Peter Maydell wrote:
> On Tue, 1 Mar 2022 at 20:47, Christian Schoenebeck
>
> <qemu_oss@crudebyte.com> wrote:
> > Function qemu_dirent_dup() is currently only used by 9pfs server, so move
> > it from project global header osdep.h to 9pfs specific header 9p-util.h.
> >
> > Link:
> > https://lore.kernel.org/qemu-devel/CAFEAcA_=HAUNomKD2wurSVaAHa5mrk22A1oHK
> > LWUDjk7v6Khmg@mail.gmail.com/ Based-on:
> > <20220227223522.91937-12-wwcohen@gmail.com>
> > Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > ---
> >
> > hw/9pfs/9p-util.h | 30 ++++++++++++++++++++++++++++++
> > include/qemu/osdep.h | 13 -------------
> > util/osdep.c | 21 ---------------------
> > 3 files changed, 30 insertions(+), 34 deletions(-)
> >
> > diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h
> > index 1f74d37558..8b92614e6c 100644
> > --- a/hw/9pfs/9p-util.h
> > +++ b/hw/9pfs/9p-util.h
> > @@ -112,6 +112,36 @@ static inline off_t qemu_dirent_off(struct dirent
> > *dent)>
> > #endif
> > }
> >
> > +/**
> > + * Duplicate directory entry @dent.
> > + *
> > + * It is highly recommended to use this function instead of open coding
> > + * duplication of @c dirent objects, because the actual @c struct @c
> > dirent + * size may be bigger or shorter than @c sizeof(struct dirent)
> > and correct + * handling is platform specific (see gitlab issue #841).
> > + *
> > + * @dent - original directory entry to be duplicated
> > + * @returns duplicated directory entry which should be freed with
> > g_free()
> > + */
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> since it's just code movement, but those "@c"s look a bit weird:
> are they really valid kerneldoc comment markup?
>
> thanks
> -- PMM
You are right, that's Doxygen format, not kerneldoc format.
If you don't mind I send a separate, subsequent patch that just wipes the
"@c"s away, and leave this patch as-is (as this one is pure refactoring).
Alternatively I could replace the "@c"s by kerneldoc's solution which
apparently is "::foo" I think ("foo" being the inlined C code).
Best regards,
Christian Schoenebeck
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] 9pfs: move qemu_dirent_dup() from osdep -> 9p-util
2022-03-02 14:16 ` Christian Schoenebeck
@ 2022-03-02 16:59 ` Peter Maydell
0 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2022-03-02 16:59 UTC (permalink / raw)
To: Christian Schoenebeck; +Cc: qemu-devel, Greg Kurz
On Wed, 2 Mar 2022 at 14:16, Christian Schoenebeck
<qemu_oss@crudebyte.com> wrote:
>
> On Dienstag, 1. März 2022 22:59:43 CET Peter Maydell wrote:
> > On Tue, 1 Mar 2022 at 20:47, Christian Schoenebeck
> >
> > <qemu_oss@crudebyte.com> wrote:
> > > Function qemu_dirent_dup() is currently only used by 9pfs server, so move
> > > it from project global header osdep.h to 9pfs specific header 9p-util.h.
> > >
> > > Link:
> > > https://lore.kernel.org/qemu-devel/CAFEAcA_=HAUNomKD2wurSVaAHa5mrk22A1oHK
> > > LWUDjk7v6Khmg@mail.gmail.com/ Based-on:
> > > <20220227223522.91937-12-wwcohen@gmail.com>
> > > Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > > ---
> > Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> >
> > since it's just code movement, but those "@c"s look a bit weird:
> > are they really valid kerneldoc comment markup?
> You are right, that's Doxygen format, not kerneldoc format.
>
> If you don't mind I send a separate, subsequent patch that just wipes the
> "@c"s away, and leave this patch as-is (as this one is pure refactoring).
Yes, I agree that should be a separate patch, and just removing
the formatting is the simplest approach.
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] 9pfs: move qemu_dirent_dup() from osdep -> 9p-util
2022-03-01 20:33 [PATCH] 9pfs: move qemu_dirent_dup() from osdep -> 9p-util Christian Schoenebeck
2022-03-01 21:59 ` Peter Maydell
@ 2022-03-03 12:21 ` Christian Schoenebeck
1 sibling, 0 replies; 5+ messages in thread
From: Christian Schoenebeck @ 2022-03-03 12:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Greg Kurz, Peter Maydell
On Dienstag, 1. März 2022 21:33:49 CET Christian Schoenebeck wrote:
> Function qemu_dirent_dup() is currently only used by 9pfs server, so move
> it from project global header osdep.h to 9pfs specific header 9p-util.h.
>
> Link:
> https://lore.kernel.org/qemu-devel/CAFEAcA_=HAUNomKD2wurSVaAHa5mrk22A1oHKLW
> UDjk7v6Khmg@mail.gmail.com/ Based-on:
> <20220227223522.91937-12-wwcohen@gmail.com>
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
> hw/9pfs/9p-util.h | 30 ++++++++++++++++++++++++++++++
> include/qemu/osdep.h | 13 -------------
> util/osdep.c | 21 ---------------------
> 3 files changed, 30 insertions(+), 34 deletions(-)
Queued on 9p.next:
https://github.com/cschoenebeck/qemu/commits/9p.next
Thanks!
Best regards,
Christian Schoenebeck
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-03 12:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-01 20:33 [PATCH] 9pfs: move qemu_dirent_dup() from osdep -> 9p-util Christian Schoenebeck
2022-03-01 21:59 ` Peter Maydell
2022-03-02 14:16 ` Christian Schoenebeck
2022-03-02 16:59 ` Peter Maydell
2022-03-03 12:21 ` Christian Schoenebeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).