From 10c2fb0fe14972828fcdf740ff159c8668315ccf Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Sun, 6 Jan 2019 10:29:47 +0000
Subject: [PATCH] direntry.c: cleanup -Wnull-dereference warning
Found by GCC8
direntry.c:918:21: error: potential null pointer dereference [-Werror=null-dereference]
entry->ino->ent = entry;
~~~~~~~~~~~~~~~~^~~~~~~
direntry.c:1276:36: error: potential null pointer dereference [-Werror=null-dereference]
if ((VFSDATA (path_element)->flags & VFS_S_USETMP) != 0)
direntry.c:1334:32: error: potential null pointer dereference [-Werror=null-dereference]
if ((VFSDATA (path_element)->flags & VFS_S_USETMP) != 0 && fh->ino->localname != NULL)
direntry.c:1314:35: error: potential null pointer dereference [-Werror=null-dereference]
if (VFSDATA (path_element)->linear_start != NULL)
direntry.c:1325:14: error: potential null pointer dereference [-Werror=null-dereference]
if (s->fh_open != NULL && s->fh_open (path_element->class, fh, flags, mode) != 0)
~^~~~~~~~~
Signed-off-by: Andreas Mohr <and@gmx.li>
---
lib/vfs/direntry.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/lib/vfs/direntry.c b/lib/vfs/direntry.c
index 48a5b760c..bfcfa7354 100644
a
|
b
|
vfs_s_new_entry (struct vfs_class *me, const char *name, struct vfs_s_inode *ino |
914 | 914 | entry = g_new0 (struct vfs_s_entry, 1); |
915 | 915 | |
916 | 916 | entry->name = g_strdup (name); |
| 917 | |
917 | 918 | entry->ino = inode; |
918 | | entry->ino->ent = entry; |
| 919 | if (entry->ino != NULL) |
| 920 | entry->ino->ent = entry; |
919 | 921 | CALL (init_entry) (me, entry); |
920 | 922 | |
921 | 923 | return entry; |
… |
… |
vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode) |
1237 | 1239 | const char *q; |
1238 | 1240 | struct vfs_s_inode *ino; |
1239 | 1241 | const vfs_path_element_t *path_element; |
| 1242 | struct vfs_s_subclass *s; |
1240 | 1243 | |
1241 | 1244 | path_element = vfs_path_get_by_index (vpath, -1); |
1242 | 1245 | |
… |
… |
vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode) |
1273 | 1276 | ent = vfs_s_generate_entry (path_element->class, name, dir, 0755); |
1274 | 1277 | ino = ent->ino; |
1275 | 1278 | vfs_s_insert_entry (path_element->class, dir, ent); |
1276 | | if ((VFSDATA (path_element)->flags & VFS_S_USETMP) != 0) |
| 1279 | s = VFSDATA (path_element); |
| 1280 | if (s != NULL && (s->flags & VFS_S_USETMP) != 0) |
1277 | 1281 | { |
1278 | 1282 | int tmp_handle; |
1279 | 1283 | vfs_path_t *tmp_vpath; |
… |
… |
vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode) |
1309 | 1313 | fh->linear = LS_NOT_LINEAR; |
1310 | 1314 | fh->data = NULL; |
1311 | 1315 | |
| 1316 | s = VFSDATA (path_element); |
1312 | 1317 | if (IS_LINEAR (flags)) |
1313 | 1318 | { |
1314 | | if (VFSDATA (path_element)->linear_start != NULL) |
| 1319 | if (s != NULL && s->linear_start != NULL) |
1315 | 1320 | { |
1316 | 1321 | vfs_print_message ("%s", _("Starting linear transfer...")); |
1317 | 1322 | fh->linear = LS_LINEAR_PREOPEN; |
… |
… |
vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode) |
1319 | 1324 | } |
1320 | 1325 | else |
1321 | 1326 | { |
1322 | | struct vfs_s_subclass *s; |
1323 | | |
1324 | | s = VFSDATA (path_element); |
1325 | | if (s->fh_open != NULL && s->fh_open (path_element->class, fh, flags, mode) != 0) |
| 1327 | if (s != NULL && s->fh_open != NULL && s->fh_open (path_element->class, fh, flags, mode) != 0) |
1326 | 1328 | { |
1327 | 1329 | if (s->fh_free_data != NULL) |
1328 | 1330 | s->fh_free_data (fh); |
… |
… |
vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode) |
1331 | 1333 | } |
1332 | 1334 | } |
1333 | 1335 | |
1334 | | if ((VFSDATA (path_element)->flags & VFS_S_USETMP) != 0 && fh->ino->localname != NULL) |
| 1336 | if (s != NULL && (s->flags & VFS_S_USETMP) != 0 && fh->ino->localname != NULL) |
1335 | 1337 | { |
1336 | 1338 | fh->handle = open (fh->ino->localname, NO_LINEAR (flags), mode); |
1337 | 1339 | if (fh->handle == -1) |