[PATCH 05/13] android: binder: refactor binder_transact transaction buffer loop

Dan Carpenter dan.carpenter at oracle.com
Fri May 29 10:25:59 UTC 2015


On Thu, May 28, 2015 at 04:08:23PM -0700, Riley Andrews wrote:
> +static int binder_transaction_buffer_acquire(
> +	struct binder_transaction *t, struct binder_transaction_data *tr,
> +	struct binder_thread *thread, struct binder_transaction *in_reply_to)
> +{
> +	struct binder_proc *proc = thread->proc;
> +	binder_size_t *offp, *off_end, off_min;
> +	struct flat_binder_object *fp;
> +	uint32_t result;
> +
> +	if (!IS_ALIGNED(tr->offsets_size, sizeof(binder_size_t))) {
> +		binder_user_error("%d:%d got transaction with invalid offsets size, %lld\n",
> +				  proc->pid, thread->pid,
> +				  (u64)tr->offsets_size);
> +		return BR_FAILED_REPLY;


This smells like a behavior change.  In the original code we called
trace_binder_transaction_failed_buffer_release().  Are you sure it's
correct?

Naming the labels after the goto location is an anti-pattern.

	aaa = kmalloc();
	if (!aaa)
		goto kmalloc_failed;

The label name doesn't provide useful information compared to the line
before.  If binder_transaction_buffer_acquire() fails we say "goto
err_translate_failed;" but actually translate didn't fail because we
haven't yet attempted to translate so the little information the label
does provide is misleading.  Grumble grumble etc.  Also "error:" is a
meaningless label name.  Name labels after what the label does
"goto release_buffer;".

regards,
dan carpenter



More information about the devel mailing list