Whamcloud - gitweb
LU-15420 uapi: avoid gcc-11 -Werror=stringop-overread
[fs/lustre-release.git] / lustre / include / uapi / linux / lustre / lustre_user.h
index eaadaca..edc4511 100644 (file)
  *
  * @{
  */
+#ifndef __KERNEL__
+# define __USE_ISOC99  1
+# include <stdbool.h>
+# include <stdio.h> /* snprintf() */
+# include <sys/stat.h>
+
+# define __USE_GNU      1
+# define __USE_XOPEN2K8  1
+# define FILEID_LUSTRE 0x97 /* for name_to_handle_at() (and llapi_fd2fid()) */
+#endif /* !__KERNEL__ */
 
 #include <linux/fs.h>
 #include <linux/limits.h>
 #include <linux/lustre/lustre_fiemap.h>
 #include <linux/lustre/lustre_ver.h>
 
-#ifndef __KERNEL__
-# define __USE_ISOC99  1
-# include <stdbool.h>
-# include <stdio.h> /* snprintf() */
-# include <sys/stat.h>
-# define FILEID_LUSTRE 0x97 /* for name_to_handle_at() (and llapi_fd2fid()) */
-#endif /* !__KERNEL__ */
-
 #if defined(__cplusplus)
 extern "C" {
 #endif
@@ -1985,16 +1987,14 @@ static inline char *changelog_rec_name(const struct changelog_rec *rec)
                (enum changelog_rec_extra_flags)(cref & CLFE_SUPPORTED));
 }
 
-static inline __kernel_size_t changelog_rec_snamelen(const struct changelog_rec *rec)
+static inline char *changelog_rec_sname(const struct changelog_rec *rec)
 {
-       return rec->cr_namelen - strlen(changelog_rec_name(rec)) - 1;
+       return strchrnul(changelog_rec_name(rec), '\0') + 1;
 }
 
-static inline char *changelog_rec_sname(const struct changelog_rec *rec)
+static inline __kernel_size_t changelog_rec_snamelen(const struct changelog_rec *rec)
 {
-       char *cr_name = changelog_rec_name(rec);
-
-       return cr_name + strlen(cr_name) + 1;
+       return strlen(changelog_rec_sname(rec));
 }
 
 /**