From patchwork Thu Feb 27 21:14:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410505 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DACF7138D for ; Thu, 27 Feb 2020 21:40:05 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C2C6524690 for ; Thu, 27 Feb 2020 21:40:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2C6524690 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 096FC34A6D0; Thu, 27 Feb 2020 13:32:37 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 8444221FE9E for ; Thu, 27 Feb 2020 13:20:31 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 52A008F23; Thu, 27 Feb 2020 16:18:18 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 515B946C; Thu, 27 Feb 2020 16:18:18 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:14:56 -0500 Message-Id: <1582838290-17243-429-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 428/622] lustre: uapi: Make lustre_user.h c++-legal X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Rob Latham recent c++ compilers did not like some of the C idioms used in this header: - C++ checks the types of enums more forecfully than is done in C - signed vs unsigned comparisons will generate a warning under g++ - "invalid suffix on literal" warning: Lustre is not trying to generate a new literal identifier. WC-bug-id: https://jira.whamcloud.com/browse/LU-12527 Lustre-commit: 14b11dc3526a ("LU-12527 utils: Make lustre_user.h c++-legal") Signed-off-by: Rob Latham Reviewed-on: https://review.whamcloud.com/35471 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- include/uapi/linux/lustre/lustre_user.h | 139 +++++++++++++++++++------------- 1 file changed, 84 insertions(+), 55 deletions(-) diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h index db36ce5..3016b73 100644 --- a/include/uapi/linux/lustre/lustre_user.h +++ b/include/uapi/linux/lustre/lustre_user.h @@ -885,7 +885,7 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) #define ALLQUOTA 255 /* set all quota */ -static inline char *qtype_name(int qtype) +static inline const char *qtype_name(int qtype) { switch (qtype) { case USRQUOTA: @@ -1206,7 +1206,8 @@ static inline enum hsm_event hsm_get_cl_event(__u16 flags) static inline void hsm_set_cl_event(enum changelog_rec_flags *clf_flags, enum hsm_event he) { - *clf_flags |= (he << CLF_HSM_EVENT_L); + *clf_flags = (enum changelog_rec_flags) + (*clf_flags | (he << CLF_HSM_EVENT_L)); } static inline __u16 hsm_get_cl_flags(enum changelog_rec_flags clf_flags) @@ -1217,7 +1218,8 @@ static inline __u16 hsm_get_cl_flags(enum changelog_rec_flags clf_flags) static inline void hsm_set_cl_flags(enum changelog_rec_flags *clf_flags, unsigned int bits) { - *clf_flags |= (bits << CLF_HSM_FLAG_L); + *clf_flags = (enum changelog_rec_flags) + (*clf_flags | (bits << CLF_HSM_FLAG_L)); } static inline int hsm_get_cl_error(enum changelog_rec_flags clf_flags) @@ -1228,7 +1230,8 @@ static inline int hsm_get_cl_error(enum changelog_rec_flags clf_flags) static inline void hsm_set_cl_error(enum changelog_rec_flags *clf_flags, unsigned int error) { - *clf_flags |= (error << CLF_HSM_ERR_L); + *clf_flags = (enum changelog_rec_flags) + (*clf_flags | (error << CLF_HSM_ERR_L)); } enum changelog_rec_extra_flags { @@ -1370,9 +1373,11 @@ static inline size_t changelog_rec_size(struct changelog_rec *rec) enum changelog_rec_extra_flags cref = CLFE_INVALID; if (rec->cr_flags & CLF_EXTRA_FLAGS) - cref = changelog_rec_extra_flags(rec)->cr_extra_flags; + cref = (enum changelog_rec_extra_flags) + changelog_rec_extra_flags(rec)->cr_extra_flags; - return changelog_rec_offset(rec->cr_flags, cref); + return changelog_rec_offset((enum changelog_rec_flags)rec->cr_flags, + cref); } static inline size_t changelog_rec_varsize(struct changelog_rec *rec) @@ -1383,7 +1388,8 @@ static inline size_t changelog_rec_varsize(struct changelog_rec *rec) static inline struct changelog_ext_rename *changelog_rec_rename(struct changelog_rec *rec) { - enum changelog_rec_flags crf = rec->cr_flags & CLF_VERSION; + enum changelog_rec_flags crf = (enum changelog_rec_flags) + (rec->cr_flags & CLF_VERSION); return (struct changelog_ext_rename *)((char *)rec + changelog_rec_offset(crf, @@ -1394,8 +1400,8 @@ struct changelog_ext_rename *changelog_rec_rename(struct changelog_rec *rec) static inline struct changelog_ext_jobid *changelog_rec_jobid(struct changelog_rec *rec) { - enum changelog_rec_flags crf = rec->cr_flags & - (CLF_VERSION | CLF_RENAME); + enum changelog_rec_flags crf = (enum changelog_rec_flags) + (rec->cr_flags & (CLF_VERSION | CLF_RENAME)); return (struct changelog_ext_jobid *)((char *)rec + changelog_rec_offset(crf, @@ -1407,8 +1413,8 @@ struct changelog_ext_jobid *changelog_rec_jobid(struct changelog_rec *rec) struct changelog_ext_extra_flags *changelog_rec_extra_flags( const struct changelog_rec *rec) { - enum changelog_rec_flags crf = rec->cr_flags & - (CLF_VERSION | CLF_RENAME | CLF_JOBID); + enum changelog_rec_flags crf = (enum changelog_rec_flags) + (rec->cr_flags & (CLF_VERSION | CLF_RENAME | CLF_JOBID)); return (struct changelog_ext_extra_flags *)((char *)rec + changelog_rec_offset(crf, @@ -1420,8 +1426,9 @@ struct changelog_ext_extra_flags *changelog_rec_extra_flags( struct changelog_ext_uidgid *changelog_rec_uidgid( const struct changelog_rec *rec) { - enum changelog_rec_flags crf = rec->cr_flags & - (CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS); + enum changelog_rec_flags crf = (enum changelog_rec_flags) + (rec->cr_flags & + (CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS)); return (struct changelog_ext_uidgid *)((char *)rec + changelog_rec_offset(crf, @@ -1432,13 +1439,15 @@ struct changelog_ext_uidgid *changelog_rec_uidgid( static inline struct changelog_ext_nid *changelog_rec_nid(const struct changelog_rec *rec) { - enum changelog_rec_flags crf = rec->cr_flags & - (CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS); + enum changelog_rec_flags crf = (enum changelog_rec_flags) + (rec->cr_flags & + (CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS)); enum changelog_rec_extra_flags cref = CLFE_INVALID; if (rec->cr_flags & CLF_EXTRA_FLAGS) - cref = changelog_rec_extra_flags(rec)->cr_extra_flags & - CLFE_UIDGID; + cref = (enum changelog_rec_extra_flags) + (changelog_rec_extra_flags(rec)->cr_extra_flags & + CLFE_UIDGID); return (struct changelog_ext_nid *)((char *)rec + changelog_rec_offset(crf, cref)); @@ -1449,13 +1458,16 @@ struct changelog_ext_nid *changelog_rec_nid(const struct changelog_rec *rec) struct changelog_ext_openmode *changelog_rec_openmode( const struct changelog_rec *rec) { - enum changelog_rec_flags crf = rec->cr_flags & - (CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS); + enum changelog_rec_flags crf = (enum changelog_rec_flags) + (rec->cr_flags & + (CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS)); enum changelog_rec_extra_flags cref = CLFE_INVALID; - if (rec->cr_flags & CLF_EXTRA_FLAGS) - cref = changelog_rec_extra_flags(rec)->cr_extra_flags & - (CLFE_UIDGID | CLFE_NID); + if (rec->cr_flags & CLF_EXTRA_FLAGS) { + cref = (enum changelog_rec_extra_flags) + (changelog_rec_extra_flags(rec)->cr_extra_flags & + (CLFE_UIDGID | CLFE_NID)); + } return (struct changelog_ext_openmode *)((char *)rec + changelog_rec_offset(crf, cref)); @@ -1466,13 +1478,15 @@ struct changelog_ext_openmode *changelog_rec_openmode( struct changelog_ext_xattr *changelog_rec_xattr( const struct changelog_rec *rec) { - enum changelog_rec_flags crf = rec->cr_flags & - (CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS); + enum changelog_rec_flags crf = (enum changelog_rec_flags) + (rec->cr_flags & + (CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS)); enum changelog_rec_extra_flags cref = CLFE_INVALID; if (rec->cr_flags & CLF_EXTRA_FLAGS) - cref = changelog_rec_extra_flags(rec)->cr_extra_flags & - (CLFE_UIDGID | CLFE_NID | CLFE_OPEN); + cref = (enum changelog_rec_extra_flags) + (changelog_rec_extra_flags(rec)->cr_extra_flags & + (CLFE_UIDGID | CLFE_NID | CLFE_OPEN)); return (struct changelog_ext_xattr *)((char *)rec + changelog_rec_offset(crf, cref)); @@ -1484,10 +1498,12 @@ static inline char *changelog_rec_name(struct changelog_rec *rec) enum changelog_rec_extra_flags cref = CLFE_INVALID; if (rec->cr_flags & CLF_EXTRA_FLAGS) - cref = changelog_rec_extra_flags(rec)->cr_extra_flags; + cref = (enum changelog_rec_extra_flags) + changelog_rec_extra_flags(rec)->cr_extra_flags; - return (char *)rec + changelog_rec_offset(rec->cr_flags & CLF_SUPPORTED, - cref & CLFE_SUPPORTED); + return (char *)rec + changelog_rec_offset( + (enum changelog_rec_flags)(rec->cr_flags & CLF_SUPPORTED), + (enum changelog_rec_extra_flags)(cref & CLFE_SUPPORTED)); } static inline size_t changelog_rec_snamelen(struct changelog_rec *rec) @@ -1535,8 +1551,10 @@ static inline void changelog_remap_rec(struct changelog_rec *rec, char *jid_mov, *rnm_mov; enum changelog_rec_extra_flags cref = CLFE_INVALID; - crf_wanted &= CLF_SUPPORTED; - cref_want &= CLFE_SUPPORTED; + crf_wanted = (enum changelog_rec_flags) + (crf_wanted & CLF_SUPPORTED); + cref_want = (enum changelog_rec_extra_flags) + (cref_want & CLFE_SUPPORTED); if ((rec->cr_flags & CLF_SUPPORTED) == crf_wanted) { if (!(rec->cr_flags & CLF_EXTRA_FLAGS) || @@ -1554,38 +1572,49 @@ static inline void changelog_remap_rec(struct changelog_rec *rec, /* Locations of extensions in the remapped record */ if (rec->cr_flags & CLF_EXTRA_FLAGS) { xattr_mov = (char *)rec + - changelog_rec_offset(crf_wanted & CLF_SUPPORTED, - cref_want & ~CLFE_XATTR); + changelog_rec_offset((enum changelog_rec_flags) + (crf_wanted & CLF_SUPPORTED), + (enum changelog_rec_extra_flags) + (cref_want & ~CLFE_XATTR)); omd_mov = (char *)rec + - changelog_rec_offset(crf_wanted & CLF_SUPPORTED, - cref_want & ~(CLFE_OPEN | - CLFE_XATTR)); + changelog_rec_offset((enum changelog_rec_flags) + (crf_wanted & CLF_SUPPORTED), + (enum changelog_rec_extra_flags) + (cref_want & ~(CLFE_OPEN | + CLFE_XATTR))); nid_mov = (char *)rec + - changelog_rec_offset(crf_wanted & CLF_SUPPORTED, - cref_want & ~(CLFE_NID | - CLFE_OPEN | - CLFE_XATTR)); + changelog_rec_offset((enum changelog_rec_flags) + (crf_wanted & CLF_SUPPORTED), + (enum changelog_rec_extra_flags) + (cref_want & ~(CLFE_NID | + CLFE_OPEN | + CLFE_XATTR))); uidgid_mov = (char *)rec + - changelog_rec_offset(crf_wanted & CLF_SUPPORTED, - cref_want & ~(CLFE_UIDGID | - CLFE_NID | - CLFE_OPEN | - CLFE_XATTR)); - cref = changelog_rec_extra_flags(rec)->cr_extra_flags; + changelog_rec_offset((enum changelog_rec_flags) + (crf_wanted & CLF_SUPPORTED), + (enum changelog_rec_extra_flags) + (cref_want & ~(CLFE_UIDGID | + CLFE_NID | + CLFE_OPEN | + CLFE_XATTR))); + cref = (enum changelog_rec_extra_flags) + changelog_rec_extra_flags(rec)->cr_extra_flags; } ef_mov = (char *)rec + - changelog_rec_offset(crf_wanted & ~CLF_EXTRA_FLAGS, - CLFE_INVALID); + changelog_rec_offset((enum changelog_rec_flags) + (crf_wanted & ~CLF_EXTRA_FLAGS), + CLFE_INVALID); jid_mov = (char *)rec + - changelog_rec_offset(crf_wanted & - ~(CLF_EXTRA_FLAGS | CLF_JOBID), + changelog_rec_offset((enum changelog_rec_flags) + (crf_wanted & ~(CLF_EXTRA_FLAGS | + CLF_JOBID)), CLFE_INVALID); rnm_mov = (char *)rec + - changelog_rec_offset(crf_wanted & - ~(CLF_EXTRA_FLAGS | - CLF_JOBID | - CLF_RENAME), + changelog_rec_offset((enum changelog_rec_flags) + (crf_wanted & ~(CLF_EXTRA_FLAGS | + CLF_JOBID | + CLF_RENAME)), CLFE_INVALID); /* Move the extension fields to the desired positions */ @@ -1824,7 +1853,7 @@ static inline ssize_t hur_len(struct hsm_user_request *hur) (__u64)hur->hur_request.hr_itemcount * sizeof(hur->hur_user_item[0]) + hur->hur_request.hr_data_len; - if (size != (ssize_t)size) + if ((ssize_t)size < 0) return -1; return size;