Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753256AbbBANir (ORCPT ); Sun, 1 Feb 2015 08:38:47 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:38651 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752905AbbBANiq (ORCPT ); Sun, 1 Feb 2015 08:38:46 -0500 Date: Sun, 1 Feb 2015 19:08:36 +0530 From: Vaishali Thakkar To: David Teigland , Christine Caulfield Cc: cluster-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH] dlm: Use put_unaligned_be16 Message-ID: <20150201133836.GA6056@vaishali-Ideapad-Z570> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2363 Lines: 87 This patch introduces the use of function put_unaligned_be16. This is done using Coccinelle and semantic patch used is as follows: @a@ typedef u16, __be16, uint16_t; {u16,__be16,uint16_t} e16; identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_be16(y); <+... when != tmp ( - memcpy(ptr, (T)&tmp, \(2\|sizeof(u16)\|sizeof(__be16)\|sizeof(uint16_t)\|sizeof(e16)\)); + put_unaligned_be16(y,ptr); | - memcpy(ptr, (T)&tmp, ...); + put_unaligned_be16(y,ptr); ) ...+> ? tmp = e @@ type T; identifier a.tmp; @@ - T tmp; ...when != tmp Signed-off-by: Vaishali Thakkar --- fs/dlm/dir.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c index d975851..ad77747 100644 --- a/fs/dlm/dir.c +++ b/fs/dlm/dir.c @@ -239,7 +239,6 @@ void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen, struct list_head *list; struct dlm_rsb *r; int offset = 0, dir_nodeid; - __be16 be_namelen; down_read(&ls->ls_root_sem); @@ -275,15 +274,15 @@ void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen, if (offset + sizeof(uint16_t)*2 + r->res_length > outlen) { /* Write end-of-block record */ - be_namelen = cpu_to_be16(0); - memcpy(outbuf + offset, &be_namelen, sizeof(__be16)); + + put_unaligned_be16(0, outbuf + offset); offset += sizeof(__be16); ls->ls_recover_dir_sent_msg++; goto out; } - be_namelen = cpu_to_be16(r->res_length); - memcpy(outbuf + offset, &be_namelen, sizeof(__be16)); + + put_unaligned_be16(r->res_length, outbuf + offset); offset += sizeof(__be16); memcpy(outbuf + offset, r->res_name, r->res_length); offset += r->res_length; @@ -297,8 +296,8 @@ void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen, if ((list == &ls->ls_root_list) && (offset + sizeof(uint16_t) <= outlen)) { - be_namelen = cpu_to_be16(0xFFFF); - memcpy(outbuf + offset, &be_namelen, sizeof(__be16)); + + put_unaligned_be16(0xFFFF, outbuf + offset); offset += sizeof(__be16); ls->ls_recover_dir_sent_msg++; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/