lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <eb4713e3-ccc5-4848-800e-dbf30158b8af@gmx.net>
Date: Fri, 11 Oct 2024 12:54:35 +0200
From: Stefan Wahren <wahrenst@....net>
To: Umang Jain <umang.jain@...asonboard.com>,
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>
Cc: linux-rpi-kernel@...ts.infradead.org,
 linux-arm-kernel@...ts.infradead.org, linux-staging@...ts.linux.dev,
 linux-kernel@...r.kernel.org,
 Kieran Bingham <kieran.bingham@...asonboard.com>,
 Dan Carpenter <dan.carpenter@...aro.org>,
 Laurent Pinchart <laurent.pinchart@...asonboard.com>
Subject: Re: [PATCH 4/8] staging: vchiq_core: Lower indentation of a
 conditional block

Hi Umang,

Am 11.10.24 um 09:22 schrieb Umang Jain:
> Lower indentation of 'if (bulk->data && service->instance)'
> conditional block. This is achieved introducing a early check for
> (!bulk->data || !service->instance) and using a goto label 'complete'
> if it evaluates to true.
>
> No functional changes intended in this patch.
>
> Signed-off-by: Umang Jain <umang.jain@...asonboard.com>
> ---
>   .../interface/vchiq_arm/vchiq_core.c          | 61 ++++++++++---------
>   1 file changed, 31 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> index 15257cf66fa4..b95443043c27 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> @@ -1326,44 +1326,45 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
>   		struct vchiq_bulk *bulk =
>   			&queue->bulks[BULK_INDEX(queue->remove)];
>
> +		if (!bulk->data || !service->instance)
> +			goto complete;
> +
>   		/*
>   		 * Only generate callbacks for non-dummy bulk
>   		 * requests, and non-terminated services
>   		 */
> -		if (bulk->data && service->instance) {
> -			if (bulk->actual != VCHIQ_BULK_ACTUAL_ABORTED) {
> -				if (bulk->dir == VCHIQ_BULK_TRANSMIT) {
> -					VCHIQ_SERVICE_STATS_INC(service, bulk_tx_count);
> -					VCHIQ_SERVICE_STATS_ADD(service, bulk_tx_bytes,
> -								bulk->actual);
> -				} else {
> -					VCHIQ_SERVICE_STATS_INC(service, bulk_rx_count);
> -					VCHIQ_SERVICE_STATS_ADD(service, bulk_rx_bytes,
> -								bulk->actual);
> -				}
> +		if (bulk->actual != VCHIQ_BULK_ACTUAL_ABORTED) {
> +			if (bulk->dir == VCHIQ_BULK_TRANSMIT) {
> +				VCHIQ_SERVICE_STATS_INC(service, bulk_tx_count);
> +				VCHIQ_SERVICE_STATS_ADD(service, bulk_tx_bytes,
> +							bulk->actual);
>   			} else {
> -				VCHIQ_SERVICE_STATS_INC(service, bulk_aborted_count);
> -			}
> -			if (bulk->mode == VCHIQ_BULK_MODE_BLOCKING) {
> -				struct bulk_waiter *waiter;
> -
> -				spin_lock(&service->state->bulk_waiter_spinlock);
> -				waiter = bulk->userdata;
> -				if (waiter) {
> -					waiter->actual = bulk->actual;
> -					complete(&waiter->event);
> -				}
> -				spin_unlock(&service->state->bulk_waiter_spinlock);
> -			} else if (bulk->mode == VCHIQ_BULK_MODE_CALLBACK) {
> -				enum vchiq_reason reason =
> -						get_bulk_reason(bulk);
> -				status = make_service_callback(service, reason,	NULL,
> -							       bulk->userdata);
> -				if (status == -EAGAIN)
> -					break;
> +				VCHIQ_SERVICE_STATS_INC(service, bulk_rx_count);
> +				VCHIQ_SERVICE_STATS_ADD(service, bulk_rx_bytes,
> +							bulk->actual);
>   			}
> +		} else {
> +			VCHIQ_SERVICE_STATS_INC(service, bulk_aborted_count);
>   		}
> +		if (bulk->mode == VCHIQ_BULK_MODE_BLOCKING) {
> +			struct bulk_waiter *waiter;
>
> +			spin_lock(&service->state->bulk_waiter_spinlock);
> +			waiter = bulk->userdata;
> +			if (waiter) {
> +				waiter->actual = bulk->actual;
> +				complete(&waiter->event);
> +			}
> +			spin_unlock(&service->state->bulk_waiter_spinlock);
> +		} else if (bulk->mode == VCHIQ_BULK_MODE_CALLBACK) {
> +			enum vchiq_reason reason =
> +					get_bulk_reason(bulk);
> +			status = make_service_callback(service, reason,	NULL,
> +						       bulk->userdata);
> +			if (status == -EAGAIN)
> +				break;
> +		}
> +complete:
I would consider goto labels within a while loop as error prone and
ugly. Maybe moving the enclosing code into a separate function would be
a nicer approach?

Regards
>   		queue->remove++;
>   		complete(&service->bulk_remove_event);
>   	}


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ