From: Greg KH <gregkh@linuxfoundation.org>
To: Bhumika Goyal <bhumirks@gmail.com>
Cc: <outreachy-kernel@googlegroups.com>
Subject: Re: [Outreachy kernel] [PATCH v2 4/5] Staging: lustre: Use min or max instead of ternary operator
Date: Fri, 26 Feb 2016 06:18:07 +0000 [thread overview]
Message-ID: <20160226061806.GA22168@kroah.com> (raw)
In-Reply-To: <8af7a8ccdaed489dabc1ee84571ff8fe2d8b3368.1456241358.git.bhumirks@gmail.com>
On Tue, Feb 23, 2016 at 09:17:19PM +0530, Bhumika Goyal wrote:
> Replace ternary operators with macros min/max as they are
> shorter and thus increases code readability. Macro min returns the
> minimum and max returns maximum of the two compared values.
> Made a semantic patch for changes:
>
> @@
> type T;
> T x;
> T y;
> @@
> (
> - x < y ? x : y
> + min(x,y)
> |
> - x > y ? x : y
> + max(x,y)
> )
>
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> ---
> Changes in v2:
> Use min()/max() instead of min_t()/max_t() as the values passed in the
> macros are of same type.
>
> drivers/staging/lustre/lustre/include/lustre_disk.h | 6 ++----
> drivers/staging/lustre/lustre/osc/osc_request.c | 2 +-
> drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +-
> 3 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h
> index 7c6933f..8254428 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_disk.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h
> @@ -331,14 +331,12 @@ static inline void lcd_cpu_to_le(struct lsd_client_data *lcd,
>
> static inline __u64 lcd_last_transno(struct lsd_client_data *lcd)
> {
> - return (lcd->lcd_last_transno > lcd->lcd_last_close_transno ?
> - lcd->lcd_last_transno : lcd->lcd_last_close_transno);
> + return max(lcd->lcd_last_transno, lcd->lcd_last_close_transno);
> }
>
> static inline __u64 lcd_last_xid(struct lsd_client_data *lcd)
> {
> - return (lcd->lcd_last_xid > lcd->lcd_last_close_xid ?
> - lcd->lcd_last_xid : lcd->lcd_last_close_xid);
> + return max(lcd->lcd_last_xid, lcd->lcd_last_close_xid);
> }
>
> /****************** superblock additional info *********************/
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 43b11c6..b48c23e 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -1170,7 +1170,7 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count,
> }
>
> while (nob > 0 && pg_count > 0) {
> - int count = pga[i]->count > nob ? nob : pga[i]->count;
> + int count = min(nob, pga[i]->count);
>
> /* corrupt the data before we compute the checksum, to
> * simulate an OST->client data error */
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c
> index 64eaa0e..dc2996f 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/events.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c
> @@ -254,7 +254,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt,
>
> new_seq = (sec << REQS_SEC_SHIFT) |
> (usec << REQS_USEC_SHIFT) |
> - (svcpt->scp_cpt < 0 ? 0 : svcpt->scp_cpt);
> + (max(0, svcpt->scp_cpt));
>
> if (new_seq > svcpt->scp_hist_seq) {
> /* This handles the initial case of scp_hist_seq == 0 or
Doesn't apply due to other changes in this code from other developers.
Please rebase and resend.
thanks,
greg k-h
next prev parent reply other threads:[~2016-02-26 6:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-23 15:47 [PATCH v2 0/5] Staging: Replace ternary operators with macros min/max Bhumika Goyal
2016-02-23 15:47 ` [PATCH v2 1/5] Staging: rtl8723au: Use min macro instead of ternary operator Bhumika Goyal
2016-02-23 15:47 ` [PATCH v2 2/5] Staging: rdma: " Bhumika Goyal
2016-02-23 15:47 ` [PATCH v2 3/5] Staging: gdm724x: Use min " Bhumika Goyal
2016-02-23 15:47 ` [PATCH v2 4/5] Staging: lustre: Use min or max " Bhumika Goyal
2016-02-26 6:18 ` Greg KH [this message]
2016-02-23 15:47 ` [PATCH v2 5/5] Staging: rts5208: Use min " Bhumika Goyal
2016-02-26 10:04 ` [PATCH v3 0/5] Staging: Replace ternary operators with macros min/max Bhumika Goyal
2016-02-26 10:04 ` [PATCH v3 1/5] Staging: rtl8723au: Use min macro instead of ternary operator Bhumika Goyal
2016-02-26 10:04 ` [PATCH v3 2/5] Staging: rdma: " Bhumika Goyal
2016-02-26 10:04 ` [PATCH v3 3/5] Staging: gdm724x: Use min " Bhumika Goyal
2016-02-26 10:04 ` [PATCH v3 4/5] Staging: lustre: Use min or max " Bhumika Goyal
2016-02-26 10:04 ` [PATCH v3 5/5] Staging: rts5208: Use min " Bhumika Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160226061806.GA22168@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=bhumirks@gmail.com \
--cc=outreachy-kernel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.