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

Re: [Xen-devel] [PATCH v9 02/10] scripts: Coccinelle script to use ERRP_AUTO_PROPAGATE()


  • To: Markus Armbruster <armbru@xxxxxxxxxx>
  • From: Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>
  • Date: Fri, 13 Mar 2020 11:06:37 +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=qpdBPje1809JXoumfIbaXWSbuRUDYLxGUjGk6oHyYzw=; b=F4in5M+OfAaRL758qX7nvK6me9poTysKtg3CWYHbE4R3E1qVJ8SEHev3EbmluPbt6s+rQUN9tYIC4Rh92NGEUwPibr8NLrMv038J+qiaNbWgqJaeR+IG5+fyNSU9G7ZKeDEl05tMeIw5UAEAOPp5xh0GxmB1JRTq5DB7VfanrZM5jg8wOcSevTwq9uqmc/LJj5ZURxBGl7A4sl8yGUUictsEEIqRSuXhRP38rljtwxoIEMbn+XmzMsdQr6ft3OtE5+rkIDHaSJEpNUleeFavY7KOyKxA+uu0gVJAlwHe3ml2EzKxxeW+It9mPnBgWsKDITqAmtDuYSUAJXDWB3KhvQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mpWI0NGgL2sVSg4q6qgzvIQzDye3lYHsgb3hLOEHYuMDKZKqnRcZ4t3srb2ZGI8SghylfjbLUKIqzbTAqWHDGDG3rFnuLcVkeJL5IOsHs8cnzl1P0Rf9rOnOYEKbZbq/pU2Q3qQ1zVuNxIebMk+89eN19tkJlZf+vO0UgUt57pRBqAwiTp7jPtsSHfgcSUrNWp7eVTWpM8rRk+JvkFvzapftSA5E9j6is5WsMo+3CSTmLy+q8CDi3bfIwxoRSixM3KUFPdlQSYdmbwRuI8IMKSPGbTQoIgNZac+IlM8IM5Cpul7mAHBdTs8trFMDz/VSIzhlGi9dwlj2xETKEWPpZg==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=vsementsov@xxxxxxxxxxxxx;
  • Cc: Kevin Wolf <kwolf@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>, qemu-block@xxxxxxxxxx, Paul Durrant <paul@xxxxxxx>, Laszlo Ersek <lersek@xxxxxxxxxx>, Christian Schoenebeck <qemu_oss@xxxxxxxxxxxxx>, 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>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>, Stefan Berger <stefanb@xxxxxxxxxxxxx>
  • Delivery-date: Fri, 13 Mar 2020 08:06:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

13.03.2020 10:50, Markus Armbruster wrote:
Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx> writes:

[...]
+// Warn several Error * definitions.
+@check1 disable optional_qualifier exists@
+identifier fn = rule1.fn, local_err, local_err2;
+@@
+
+ fn(..., Error ** ____, ...)
+ {
+     ...
+     Error *local_err = NULL;
+     ... when any
+     Error *local_err2 = NULL;
+     ... when any
+ }
+
+@ script:python @
+fn << check1.fn;
+@@
+
+print('Warning: function {} has several definitions of '
+      'Error * local variable'.format(fn))

Printing the positions like you do in the next rule is useful when
examining these warnings.

I decided that searching for Error * definition is simple, and better for
user to search all definitions by hand (may be more than too).

But understanding control flows is more complex thing and better to help
user with line positions.

But if you want, we can add them of course. Note, that for some reasons some
times coccinelle instead of original filename prints something like 
/tmp/...original-name...
so it don't look nice and may be a bit misleading.


+
+// Warn several propagations in control flow.
+@check2 disable optional_qualifier exists@
+identifier fn = rule1.fn;
+symbol errp;
+position p1, p2;
+@@
+
+ fn(..., Error ** ____, ...)
+ {
+     ...
+(
+     error_propagate_prepend(errp, ...);@p1
+|
+     error_propagate(errp, ...);@p1
+)
+     ...
+(
+     error_propagate_prepend(errp, ...);@p2
+|
+     error_propagate(errp, ...);@p2
+)
+     ... when any
+ }
+
+@ script:python @
+fn << check2.fn;
+p1 << check2.p1;
+p2 << check2.p2;
+@@
+
+print('Warning: function {} propagates to errp several times in '
+      'one control flow: at {}:{} and then at {}:{}'.format(
+          fn, p1[0].file, p1[0].line, p2[0].file, p2[0].line))
[...]



--
Best regards,
Vladimir

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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