浏览代码

[LibOS] Don't use uninitialized return value in walk_mounts()

ret is declared without initialization. It depends on (ret = (*walk) (mount, arg) for the initial assignment;
however, the list might be NULL and the assignment can not be performed leaving ret in un-initialized state.
Thus ret should be properly initialized in this case.

Signed-off-by: Gary <gang1.wang@intel.com>
Gary 6 年之前
父节点
当前提交
4a55dac44a
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      LibOS/shim/src/fs/shim_fs.c

+ 1 - 1
LibOS/shim/src/fs/shim_fs.c

@@ -508,7 +508,7 @@ int walk_mounts (int (*walk) (struct shim_mount * mount, void * arg),
                  void * arg)
 {
     struct shim_mount * mount, * n;
-    int ret;
+    int ret = 0;
     int nsrched = 0;
 
     lock(mount_list_lock);