You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2023/01/20 08:44:23 UTC
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #8194: fs: Avoid accessing filep fields if it is NULL & add DEBUGASSERTs
pkarashchenko commented on code in PR #8194:
URL: https://github.com/apache/nuttx/pull/8194#discussion_r1082239504
##########
fs/inode/fs_files.c:
##########
@@ -298,7 +301,10 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist)
#endif
filep = &plist->fl_files[i][j];
- if (filep->f_inode == NULL || (filep->f_oflags & O_CLOEXEC) != 0)
+ DEBUGASSERT(filep);
+
+ if (filep && (filep->f_inode == NULL ||
+ (filep->f_oflags & O_CLOEXEC) != 0))
Review Comment:
I do not understand this. Why do we need `DEBUGASSERT(filep);` and `if (filep`? I would expect code to be
```suggestion
DEBUGASSERT(filep);
if (filep->f_inode == NULL ||
(filep->f_oflags & O_CLOEXEC) != 0)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org