You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/12/18 21:56:56 UTC

[28/50] incubator-mynewt-core git commit: Fix usage of FILE flags

Fix usage of FILE flags


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d64f5005
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d64f5005
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d64f5005

Branch: refs/heads/sensors_branch
Commit: d64f5005b283cde6e7483a19c76bb43150d3a742
Parents: ec77b34
Author: Fabio Utzig <ut...@utzig.org>
Authored: Fri Dec 9 09:35:16 2016 -0200
Committer: Sterling Hughes <st...@apache.org>
Committed: Sun Dec 18 13:56:16 2016 -0800

----------------------------------------------------------------------
 fs/fatfs/src/mynewt_glue.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d64f5005/fs/fatfs/src/mynewt_glue.c
----------------------------------------------------------------------
diff --git a/fs/fatfs/src/mynewt_glue.c b/fs/fatfs/src/mynewt_glue.c
index c1dde99..0f45cfb 100644
--- a/fs/fatfs/src/mynewt_glue.c
+++ b/fs/fatfs/src/mynewt_glue.c
@@ -143,19 +143,18 @@ fatfs_open(const char *path, uint8_t access_flags, struct fs_file **out_fs_file)
     }
 
     mode = FA_OPEN_EXISTING;
-    switch (access_flags) {
-    case FS_ACCESS_READ:
+    if (access_flags & FS_ACCESS_READ) {
         mode |= FA_READ;
-        break;
-    case FS_ACCESS_WRITE:
+    }
+    if (access_flags & FS_ACCESS_WRITE) {
         mode |= FA_WRITE;
-        break;
-    case FS_ACCESS_APPEND:
+    }
+    if (access_flags & FS_ACCESS_APPEND) {
         mode |= FA_OPEN_APPEND;
-        break;
-    case FS_ACCESS_TRUNCATE:
+    }
+    if (access_flags & FS_ACCESS_TRUNCATE) {
+        mode &= ~FA_OPEN_EXISTING;
         mode |= FA_CREATE_ALWAYS;
-        break;
     }
 
     res = f_open(out_file, path, mode);
@@ -219,7 +218,7 @@ fatfs_read(struct fs_file *fs_file, uint32_t len, void *out_data,
     FRESULT res;
     FIL *file = (FIL *)fs_file;
 
-    res = f_read(file, out_data, len, out_len);
+    res = f_read(file, out_data, len, (UINT *)out_len);
     return fatfs_to_vfs_error(res);
 }