qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 06/13] 9p: darwin: Address minor differences


From: keno
Subject: [Qemu-devel] [PATCH 06/13] 9p: darwin: Address minor differences
Date: Sat, 26 May 2018 01:23:08 -0400

From: Keno Fischer <address@hidden>

- Darwin doesn't have strchrnul
- Comparisons of mode_t with -1 require an explicit cast, since mode_t
  is unsigned on Darwin.

Signed-off-by: Keno Fischer <address@hidden>
---
 hw/9pfs/9p-local.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index fd65d04..6e0b2e8 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -67,7 +67,10 @@ int local_open_nofollow(FsContext *fs_ctx, const char *path, 
int flags,
         assert(*path != '/');
 
         head = g_strdup(path);
-        c = strchrnul(path, '/');
+        /* equivalent to strchrnul(), but that is not available on Darwin */
+        c = strchr(path, '/');
+        if (!c)
+            c = path + strlen(path);
         if (*c) {
             /* Intermediate path element */
             head[c - path] = 0;
@@ -310,7 +313,7 @@ update_map_file:
     if (credp->fc_gid != -1) {
         gid = credp->fc_gid;
     }
-    if (credp->fc_mode != -1) {
+    if (credp->fc_mode != (mode_t)-1) {
         mode = credp->fc_mode;
     }
     if (credp->fc_rdev != -1) {
@@ -416,7 +419,7 @@ static int local_set_xattrat(int dirfd, const char *path, 
FsCred *credp)
             return err;
         }
     }
-    if (credp->fc_mode != -1) {
+    if (credp->fc_mode != (mode_t)-1) {
         uint32_t tmp_mode = cpu_to_le32(credp->fc_mode);
         err = fsetxattrat_nofollow(dirfd, path, "user.virtfs.mode", &tmp_mode,
                                    sizeof(mode_t), 0);
-- 
2.8.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]