Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp1882069rdb; Sun, 27 Aug 2023 01:01:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAdK3O/JnyvNf82EqCEvp9Q7Q0VRqsnBgsdoKrK8PljmGW7wRmJUkzoUbl4bXx3FzbFlCc X-Received: by 2002:a92:c5a2:0:b0:348:c57f:b016 with SMTP id r2-20020a92c5a2000000b00348c57fb016mr11335093ilt.3.1693123295748; Sun, 27 Aug 2023 01:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693123295; cv=none; d=google.com; s=arc-20160816; b=q7fbjxd/ABtXgeC4+bNlcdY4tLXwtGIMTSBqcTdA0R7U/ZPS2JlOH6vG4ZnZM9oZ4Y Zc2EzoFsK6CKg2Y+ux++kknxHU7AbqwjTvLYtm/FO8FY1D7uuGtmbSdoKibxlqyItKfL IUJJpI0i3J+ieTMAnyXKsW+//6So4DqGKJo5VDcT+El5MnZeXv6uko1sJEWNvaE1Pgj0 68DlKdqZnfFYGsXEAO/+G32T4nCVmCYsZiUi/0lU5qncjy8GzLAg9dc2TnBF02+dLcbt TGfpu0lG4aWyvZFJC9mw4iIUZh39AEvm8dnlqt8Xf/T9mRJaV4qRB210xDTgrbF/sbJ5 cahA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wa7IaVjqJPT2VoZxZRKCXnbqdDO+Ey6ddt+Shhyz4ro=; fh=1YNwm5KBWetjB3qGkhgLqh/dZnCTsWuqRk83JW6hjgE=; b=NQaG2cP+Xm9UYAtYWCJGA3Ev1/s4CWONVKkA18oDVxVFP7F6+A4BpFSvfi2/Ud2a68 X65o8AFmENFHCLZEUMeS431L7VbMa9D+ri7NwbINxp77LUY8+eAqrX6woCeEFDVnl+92 zAmJdrn+g3sK7I2ZJn/t0uNwmgf7AHSY1/sn2epARLhEhLAlARInFBWK3v2AmOBWLhwF 5bD+13yiYled0LyxRwOo/Ekod2VesMkftXA6+w7lIjh9tRzIL9B+Be0Id/kVTdctgM03 FoNJf7OVwLcDbZgYsJ7g16E/ptkkCChO3eMWUiHN21TaTeoQNeW4YVFEFN+gQ2yLzQAQ LYlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QSiV2Ous; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w188-20020a6362c5000000b0056c4189d6d9si4924571pgb.836.2023.08.27.01.00.59; Sun, 27 Aug 2023 01:01:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QSiV2Ous; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230298AbjH0Hne (ORCPT + 99 others); Sun, 27 Aug 2023 03:43:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230089AbjH0HmM (ORCPT ); Sun, 27 Aug 2023 03:42:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD8BCFA; Sun, 27 Aug 2023 00:42:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 43C4260FC9; Sun, 27 Aug 2023 07:42:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1764C433C8; Sun, 27 Aug 2023 07:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693122128; bh=I7T8JzUTvFtmo5xlDYAkNBZGkmHty16AkdRBOY1GVgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QSiV2OusxS+1LP/ke2ER4BXxgUfA9AS8ibKGapUCWxc09FyhVdx4pfCkoqNJDbku2 vqYrbcyyUWf8O/sL9tmwS5fmaN5SbWaImRWCx/fkRasROyl8kOAAEufcHZpW1c8sp9 MfRo2CTjF+m+/JdOmzWjJLdp4jEfLV6X0Wyx3Q6hqhkfwv5X5rCsdc2epDiECmVqFU LrTDO96E6gxHQ/qcKw9Zvw/eTFvH77rCgzc0xWEREjaRe2sGUo482/YAx/zOf/3ng2 l8Ek2FOvSkT2YsahiXimvJ652TtU+V4eSo76DHSovrSH/FpLz7JsZEauVMOB3PVp4V cBI789+mx2+FA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH v2 12/14] tty: n_tty: unify counts to size_t Date: Sun, 27 Aug 2023 09:41:45 +0200 Message-ID: <20230827074147.2287-13-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230827074147.2287-1-jirislaby@kernel.org> References: <20230827074147.2287-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some count types are already 'size_t' for a long time. Some were switched to 'size_t' recently. Unify the rest with those now. This allows for some min_t()s to become min()s. And make one min() an explicit min_t() as we are comparing signed 'room' to unsigned 'count'. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_tty.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index cf42b8b4ad2e..bd6cd28f734f 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -1523,27 +1523,27 @@ static void n_tty_lookahead_flow_ctrl(struct tty_struct *tty, const u8 *cp, static void n_tty_receive_buf_real_raw(const struct tty_struct *tty, const u8 *cp, - int count) + size_t count) { struct n_tty_data *ldata = tty->disc_data; size_t n, head; head = MASK(ldata->read_head); - n = min_t(size_t, count, N_TTY_BUF_SIZE - head); + n = min(count, N_TTY_BUF_SIZE - head); memcpy(read_buf_addr(ldata, head), cp, n); ldata->read_head += n; cp += n; count -= n; head = MASK(ldata->read_head); - n = min_t(size_t, count, N_TTY_BUF_SIZE - head); + n = min(count, N_TTY_BUF_SIZE - head); memcpy(read_buf_addr(ldata, head), cp, n); ldata->read_head += n; } static void n_tty_receive_buf_raw(struct tty_struct *tty, const u8 *cp, const u8 *fp, - int count) + size_t count) { struct n_tty_data *ldata = tty->disc_data; u8 flag = TTY_NORMAL; @@ -1560,7 +1560,7 @@ n_tty_receive_buf_raw(struct tty_struct *tty, const u8 *cp, const u8 *fp, static void n_tty_receive_buf_closing(struct tty_struct *tty, const u8 *cp, const u8 *fp, - int count, bool lookahead_done) + size_t count, bool lookahead_done) { u8 flag = TTY_NORMAL; @@ -1573,7 +1573,7 @@ n_tty_receive_buf_closing(struct tty_struct *tty, const u8 *cp, const u8 *fp, } static void n_tty_receive_buf_standard(struct tty_struct *tty, const u8 *cp, - const u8 *fp, int count, + const u8 *fp, size_t count, bool lookahead_done) { struct n_tty_data *ldata = tty->disc_data; @@ -1612,11 +1612,11 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty, const u8 *cp, } static void __receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp, - int count) + size_t count) { struct n_tty_data *ldata = tty->disc_data; bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty)); - size_t la_count = min_t(size_t, ldata->lookahead_count, count); + size_t la_count = min(ldata->lookahead_count, count); if (ldata->real_raw) n_tty_receive_buf_real_raw(tty, cp, count); @@ -1687,11 +1687,11 @@ static void __receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp, */ static size_t n_tty_receive_buf_common(struct tty_struct *tty, const u8 *cp, const u8 *fp, - int count, bool flow) + size_t count, bool flow) { struct n_tty_data *ldata = tty->disc_data; - size_t rcvd = 0; - int room, n, overflow; + size_t n, rcvd = 0; + int room, overflow; down_read(&tty->termios_rwsem); @@ -1724,7 +1724,7 @@ n_tty_receive_buf_common(struct tty_struct *tty, const u8 *cp, const u8 *fp, } else overflow = 0; - n = min(count, room); + n = min_t(size_t, count, room); if (!n) break; @@ -1954,9 +1954,8 @@ static inline int input_available_p(const struct tty_struct *tty, int poll) * caller holds non-exclusive %termios_rwsem; * read_tail published */ -static bool copy_from_read_buf(const struct tty_struct *tty, - u8 **kbp, - size_t *nr) +static bool copy_from_read_buf(const struct tty_struct *tty, u8 **kbp, + size_t *nr) { struct n_tty_data *ldata = tty->disc_data; @@ -2009,8 +2008,7 @@ static bool copy_from_read_buf(const struct tty_struct *tty, * caller holds non-exclusive %termios_rwsem; * read_tail published */ -static bool canon_copy_from_read_buf(const struct tty_struct *tty, - u8 **kbp, +static bool canon_copy_from_read_buf(const struct tty_struct *tty, u8 **kbp, size_t *nr) { struct n_tty_data *ldata = tty->disc_data; -- 2.42.0