[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v8 02/10] scripts: add coccinelle script to use auto propagated errp

  • To: Markus Armbruster <armbru@xxxxxxxxxx>
  • From: Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>
  • Date: Wed, 11 Mar 2020 17:05:24 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wdNWddZboibVKNd6sn2CayHx7QjB6YmjHdswUZOo4qk=; b=Mo+esbpCcRIT20dhe6enwgozX2paiz8OtONsklj14/Fhb51ZzZgae0xX5iKyLBcRYvSEJmiMMU2N8gw4gLy04bAjBx6tuREKjlE4O7yqMV0bWutd6OvjexxPCCOoV06myo3RVPL3QsjHZWvwCeYpgKBdCvnBjmGn1uiVdiBcPuobFN9HVa1AfIAddh+s/nPPNMURAHaU0yu8B8EwvCybWXg+LRBjjQa/pEuVBhAqs23msst+bVLG6lvPcBotfLmj8qyJ5St6b23zTlrJl6rJpHhp8zz5Gz/jQMr/NjvAfVSL2V5HnHwnuisI8ZtTcyByIAxhypSxM/9yaOOgyGJ3cA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lxdtm9Le83LHq6H58vka0f8z+Wur4dmNtBxdvKIV/A0/a2iOIzUKkjNaPIViJOkuMwJWJtnqR9e+QCd05AtSj3h0+wPqz0DGwBOrfX1APNi+1w4P59XpSfLpWUJs9OQvtIHhqm6vyrcKyaOZ5Chkb0QyouzC7RNH51uFwApgMoJrMYECgeU1s91XVGH3TfuB4xDgvoBKUgQtCXNoe4x0xKU6SxCisV6v+QuBxoSJEI2VPBxJY+NWMLTJgbQHmfwoqArrVQiFA3bt2tyo+MpJqi/qTjO72lvyii03Xuzrxszr1JR5qGP0HULmIDkF/vSvDcK8CPODDah7HVRZiwr9AQ==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=vsementsov@xxxxxxxxxxxxx;
  • Cc: Kevin Wolf <kwolf@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, qemu-block@xxxxxxxxxx, Paul Durrant <paul@xxxxxxx>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>, Christian Schoenebeck <qemu_oss@xxxxxxxxxxxxx>, Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>, qemu-devel@xxxxxxxxxx, Greg Kurz <groug@xxxxxxxx>, Gerd Hoffmann <kraxel@xxxxxxxxxx>, Stefan Hajnoczi <stefanha@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Max Reitz <mreitz@xxxxxxxxxx>, Laszlo Ersek <lersek@xxxxxxxxxx>, Stefan Berger <stefanb@xxxxxxxxxxxxx>
  • Delivery-date: Wed, 11 Mar 2020 14:05:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

11.03.2020 12:38, Markus Armbruster wrote:
Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx> writes:

09.03.2020 12:56, Markus Armbruster wrote:

      scripts: Coccinelle script to use auto-propagated errp


      scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE()

Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx> writes:
+// Note, that we update everything related to matched by rule1 function name
+// and local_err name. We may match something not related to the pattern
+// matched by rule1. For example, local_err may be defined with the same name
+// in different blocks inside one function, and in one block follow the
+// propagation pattern and in other block doesn't. Or we may have several
+// functions with the same name (for different configurations).

Context: rule1 matches functions that have all three of

* an Error **errp parameter

* an Error *local_err = NULL variable declaration

* an error_propagate(errp, local_err) or error_propagate_prepend(errp,
    local_err, ...) expression, where @errp is the parameter and
    @local_err is the variable.

If I understand you correctly, you're pointing out two potential issues:

1. This rule can match functions rule1 does not match if there is
another function with the same name that rule1 does match.

2. This rule matches in the entire function matched by rule1, even when
parts of that function use a different @errp or @local_err.

I figure these apply to all rules with identifier rule1.fn, not just
this one.  Correct?

Regarding 1.  There must be a better way to chain rules together, but I
don't know it.

Hmm, what about something like this:

@rule1 disable optional_qualifier exists@
identifier fn, local_err;
symbol errp;

  fn(..., Error **
- errp
+ ___errp_coccinelle_updating___
     , ...)
      Error *local_err = NULL;
     error_propagate_prepend(errp, local_err, ...);
     error_propagate(errp, local_err);


match symbol ___errp_coccinelle_updating___ in following rules in function 


@ disable optional_qualifier@
identifier fn, local_err;
symbol errp;

  fn(..., Error **
- ___errp_coccinelle_updating___
+ errp
     , ...)

- hacky, but seems not more hacky than python detection, and should work better

As simple, forceful and unsubtle as a sledgehammer.  I like it :)

Hmm, not so simple.

It leads to reindenting of function header, which is bad.

Possible solution is instead

+   ___errp_coccinelle_updating___();

but this slow down coccinelle. For example, on block.c from ~3s to 1m16s.


So, I'm returning to just a warning.

I think something simple like

identifier rule1.fn;
position p != rule1.p;

fn@p(...) {...}

@ script:python@

<print warning>

should work.

Best regards,

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.