diff mbox series

[09/10] block: move fcntl_setfl()

Message ID 20220422083639.3156978-10-marcandre.lureau@redhat.com
State New
Headers show
Series Misc cleanups | expand

Commit Message

Marc-André Lureau April 22, 2022, 8:36 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

It is only used by block/file-posix.c, move it there.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/sysemu/os-posix.h |  2 --
 block/file-posix.c        | 15 +++++++++++++++
 util/oslib-posix.c        | 15 ---------------
 3 files changed, 15 insertions(+), 17 deletions(-)

Comments

Richard Henderson April 22, 2022, 12:20 p.m. UTC | #1
On 4/22/22 01:36, marcandre.lureau@redhat.com wrote:
> +/* Sets a specific flag */
> +static int fcntl_setfl(int fd, int flag)
> +{
> +    int flags;
> +
> +    flags = fcntl(fd, F_GETFL);
> +    if (flags == -1)
> +        return -errno;
> +
> +    if (fcntl(fd, F_SETFL, flags | flag) == -1)
> +        return -errno;
> +
> +    return 0;
> +}
> +
>   static int raw_reconfigure_getfd(BlockDriverState *bs, int flags,
>                                    int *open_flags, uint64_t perm, bool force_dup,
>                                    Error **errp)
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index 543c9944b083..1c231087408f 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -794,21 +794,6 @@ size_t qemu_get_host_physmem(void)
>       return 0;
>   }
>   
> -/* Sets a specific flag */
> -int fcntl_setfl(int fd, int flag)
> -{
> -    int flags;
> -
> -    flags = fcntl(fd, F_GETFL);
> -    if (flags == -1) {
> -        return -errno;
> -    }
> -    if (fcntl(fd, F_SETFL, flags | flag) == -1) {
> -        return -errno;
> -    }
> -    return 0;
> -}

Lost braces in the move.

r~
diff mbox series

Patch

diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
index adbe19d3e468..58de7c994d85 100644
--- a/include/sysemu/os-posix.h
+++ b/include/sysemu/os-posix.h
@@ -96,8 +96,6 @@  static inline void qemu_funlockfile(FILE *f)
     funlockfile(f);
 }
 
-int fcntl_setfl(int fd, int flag);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/block/file-posix.c b/block/file-posix.c
index bfd9b2111143..1164ca9e1c6d 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1022,6 +1022,21 @@  static int raw_handle_perm_lock(BlockDriverState *bs,
     return ret;
 }
 
+/* Sets a specific flag */
+static int fcntl_setfl(int fd, int flag)
+{
+    int flags;
+
+    flags = fcntl(fd, F_GETFL);
+    if (flags == -1)
+        return -errno;
+
+    if (fcntl(fd, F_SETFL, flags | flag) == -1)
+        return -errno;
+
+    return 0;
+}
+
 static int raw_reconfigure_getfd(BlockDriverState *bs, int flags,
                                  int *open_flags, uint64_t perm, bool force_dup,
                                  Error **errp)
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 543c9944b083..1c231087408f 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -794,21 +794,6 @@  size_t qemu_get_host_physmem(void)
     return 0;
 }
 
-/* Sets a specific flag */
-int fcntl_setfl(int fd, int flag)
-{
-    int flags;
-
-    flags = fcntl(fd, F_GETFL);
-    if (flags == -1) {
-        return -errno;
-    }
-    if (fcntl(fd, F_SETFL, flags | flag) == -1) {
-        return -errno;
-    }
-    return 0;
-}
-
 int qemu_msync(void *addr, size_t length, int fd)
 {
     size_t align_mask = ~(qemu_real_host_page_size() - 1);