Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1742878
| From | Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 10/18] orangefs: use ARRAY_SIZE |
| Date | 2017-10-01 21:40 +0200 |
| Message-ID | <uvSfN-67y-55@gated-at.bofh.it> (permalink) |
| References | <uvSfL-67y-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Using the ARRAY_SIZE macro improves the readability of the code.
Found with Coccinelle with the following semantic patch:
@r depends on (org || report)@
type T;
T[] E;
position p;
@@
(
(sizeof(E)@p /sizeof(*E))
|
(sizeof(E)@p /sizeof(E[...]))
|
(sizeof(E)@p /sizeof(T))
)
Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
---
fs/orangefs/orangefs-debug.h | 4 +++-
fs/orangefs/orangefs-utils.c | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/orangefs/orangefs-debug.h b/fs/orangefs/orangefs-debug.h
index 387db17cde2b..af1ec4e809e2 100644
--- a/fs/orangefs/orangefs-debug.h
+++ b/fs/orangefs/orangefs-debug.h
@@ -14,8 +14,10 @@
#ifdef __KERNEL__
#include <linux/types.h>
+#include <linux/kernel.h>
#else
#include <stdint.h>
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
#define GOSSIP_NO_DEBUG (__u64)0
@@ -87,6 +89,6 @@ static struct __keyword_mask_s s_kmod_keyword_mask_map[] = {
};
static const int num_kmod_keyword_mask_map = (int)
- (sizeof(s_kmod_keyword_mask_map) / sizeof(struct __keyword_mask_s));
+ (ARRAY_SIZE(s_kmod_keyword_mask_map));
#endif /* __ORANGEFS_DEBUG_H */
diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
index aab6f1842963..d1fe32e4ffb3 100644
--- a/fs/orangefs/orangefs-utils.c
+++ b/fs/orangefs/orangefs-utils.c
@@ -3,6 +3,7 @@
*
* See COPYING in top-level directory.
*/
+#include <linux/kernel.h>
#include "protocol.h"
#include "orangefs-kernel.h"
#include "orangefs-dev-proto.h"
@@ -605,7 +606,7 @@ int orangefs_normalize_to_errno(__s32 error_code)
/* Convert ORANGEFS encoded errno values into regular errno values. */
} else if ((-error_code) & ORANGEFS_ERROR_BIT) {
i = (-error_code) & ~(ORANGEFS_ERROR_BIT|ORANGEFS_ERROR_CLASS_BITS);
- if (i < sizeof(PINT_errno_mapping)/sizeof(*PINT_errno_mapping))
+ if (i < ARRAY_SIZE(PINT_errno_mapping))
error_code = -PINT_errno_mapping[i];
else
error_code = -EINVAL;
--
2.14.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/18] use ARRAY_SIZE macro Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 04/18] IB/mlx5: Use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 12/18] x86: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 02/18] tracing/filter: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 16/18] media: staging: atomisp: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 06/18] drm: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
Re: [PATCH 06/18] drm: use ARRAY_SIZE Jani Nikula <jani.nikula@linux.intel.com> - 2017-10-02 09:50 +0200
Re: [PATCH 06/18] drm: use ARRAY_SIZE Thierry Reding <thierry.reding@gmail.com> - 2017-10-02 10:30 +0200
[PATCH 18/18] staging: rtlwifi: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 15/18] acpi: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
Re: [PATCH 15/18] acpi: use ARRAY_SIZE "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-10-02 14:40 +0200
[PATCH 01/18] sound: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
Re: [PATCH 01/18] sound: use ARRAY_SIZE Joe Perches <joe@perches.com> - 2017-10-02 06:20 +0200
[PATCH 09/18] nfsd: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
Re: [PATCH 09/18] nfsd: use ARRAY_SIZE Jeff Layton <jlayton@redhat.com> - 2017-10-02 13:10 +0200
[PATCH 08/18] ecryptfs: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 03/18] media: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
Re: [PATCH 03/18] media: use ARRAY_SIZE Michael Ira Krufky <mkrufky@linuxtv.org> - 2017-10-02 12:40 +0200
[PATCH 14/18] ipmi: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 07/18] scsi: bfa: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 17/18] staging: rtl8723bs: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 10/18] orangefs: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 13/18] tpm: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
[PATCH 11/18] dm space map metadata: use ARRAY_SIZE Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
Re: [PATCH 00/18] use ARRAY_SIZE macro "Tobin C. Harding" <me@tobin.cc> - 2017-10-02 00:10 +0200
Re: [PATCH 00/18] use ARRAY_SIZE macro Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-02 03:00 +0200
Re: [PATCH 00/18] use ARRAY_SIZE macro Greg KH <greg@kroah.com> - 2017-10-02 07:40 +0200
Re: [PATCH 00/18] use ARRAY_SIZE macro Mauro Carvalho Chehab <mchehab@s-opensource.com> - 2017-10-02 22:50 +0200
Re: [PATCH 05/18] net: use ARRAY_SIZE Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-10-02 15:10 +0200
csiph-web