Coccinelle archive on lore.kernel.org
 help / color / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] Moving exception handling code to the end of a function implementation with SmPL?
Date: Thu, 27 Jun 2019 17:01:06 +0200
Message-ID: <0d2aee49-16e4-0263-d37b-f41821eae17c@web.de> (raw)
In-Reply-To: <alpine.DEB.2.21.1906271653410.2627@hadrien>

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

>> Where did the Coccinelle software get the impression that anything
>> would be added too often at the end of such a function implementation?
>
> Without the semantic patch and the C source code,

You have access to data from both files already.


> I can't answer the question.

Is it more convenient to check test results for attachments again?

Regards,
Markus

[-- Attachment #2: move_error_code_assignment_to_function_end1.cocci --]
[-- Type: text/plain, Size: 323 bytes --]

@replacement@
expression info, result;
identifier target, work;
type t != void;
@@
 t work(...)
 {
 <+...
 if (...)
(
-{
-result = info;
 goto
-     target
+     e_nodev
 ;
-}
|
 {
 ...
-result = info;
 goto
-     target
+     e_nodev
 ;
 }
)
 ...+>
 target:
 ...
 return result;
+e_nodev:
+result = info;
+goto target;
 }

[-- Warning: decoded text below may be mangled --]
[-- Attachment #3: megaraid_sas-excerpt1.c --]
[-- Type: text/x-csrc; name="megaraid_sas-excerpt1.c", Size: 1277 bytes --]

// SPDX-License-Identifier: GPL-2.0-or-later

// Deleted part

static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
{
	struct megasas_iocpacket __user *user_ioc =
	    (struct megasas_iocpacket __user *)arg;
	struct megasas_iocpacket *ioc;
	struct megasas_instance *instance;
	int error;

	ioc = memdup_user(user_ioc, sizeof(*ioc));
	if (IS_ERR(ioc))
		return PTR_ERR(ioc);

	instance = megasas_lookup_instance(ioc->host_no);
	if (!instance) {
		error = -ENODEV;
		goto out_kfree_ioc;
	}

	/* Block ioctls in VF mode */
	if (instance->requestorId && !allow_vf_ioctls) {
		error = -ENODEV;
		goto out_kfree_ioc;
	}

	if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
		dev_err(&instance->pdev->dev, "Controller in crit error\n");
		error = -ENODEV;
		goto out_kfree_ioc;
	}

	if (instance->unload == 1) {
		error = -ENODEV;
		goto out_kfree_ioc;
	}

	if (down_interruptible(&instance->ioctl_sem)) {
		error = -ERESTARTSYS;
		goto out_kfree_ioc;
	}

	if  (megasas_wait_for_adapter_operational(instance)) {
		error = -ENODEV;
		goto out_up;
	}

	error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc);
out_up:
	up(&instance->ioctl_sem);

out_kfree_ioc:
	kfree(ioc);
	return error;
}

[-- Attachment #4: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  reply index

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21 17:45 Markus Elfring
2019-06-27  8:33 ` Markus Elfring
2019-06-27 11:33   ` Julia Lawall
2019-06-27 12:18     ` Markus Elfring
     [not found]       ` <alpine.DEB.2.21.1906271427250.2627@hadrien>
2019-06-27 12:45         ` Markus Elfring
2019-06-27 14:12         ` Markus Elfring
2019-06-27 14:54           ` Julia Lawall
2019-06-27 15:01             ` Markus Elfring [this message]
2019-10-31 12:27 ` Markus Elfring
2019-10-31 12:42   ` Julia Lawall
2019-10-31 13:50     ` Markus Elfring
2019-11-01  9:12   ` [Cocci] Checking the occurrence of trailing spaces in a semantic patch Markus Elfring
2019-11-01  9:38     ` Julia Lawall
2019-11-01  9:56       ` Markus Elfring
2019-11-01 11:50       ` Markus Elfring
2019-11-01 16:03       ` [Cocci] Checking code layout for adding jump targets with SmPL Markus Elfring
2019-11-01 16:12         ` Markus Elfring

Reply instructions:

You may reply publically 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=0d2aee49-16e4-0263-d37b-f41821eae17c@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@systeme.lip6.fr \
    --cc=julia.lawall@lip6.fr \
    /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

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git