libvirt/scripts/cocci-macro-file.h
Michal Privoznik 5101450263 scripts: Properly declare g_auto() stub for cocci
While being great semantic patching tool, coccinelle fails to
understand some of macros we use (including those provided by
glib). What they have in common is use of __attribute__ under the
hood. We store a list of such macros in a file. But in there,
g_auto() macro is not defined properly. Indeed, g_auto(type)
declares a local variable of given type, for instance from
cocci's POV:

  g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
  virBuffer buf = VIR_BUFFER_INITIALIZER;

are both the same declaration. Fix declaration of g_auto() stub.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-03 14:46:54 +01:00

40 lines
1.2 KiB
C

/*
* cocci-macro-file.h: simplified macro definitions for Coccinelle
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
* To be used with:
* $ spatch --macro-file scripts/cocci-macro-file.h
*/
#pragma once
#define ATTRIBUTE_NONNULL(x)
#define ATTRIBUTE_PACKED
#define G_GNUC_WARN_UNUSED_RESULT
#define G_GNUC_UNUSED
#define G_GNUC_NULL_TERMINATED
#define G_GNUC_NORETURN
#define G_GNUC_NO_INLINE
#define G_GNUC_FALLTHROUGH
#define G_GNUC_PRINTF(a, b)
#define g_autoptr(x) x##_autoptr
#define g_autofree
#define g_auto(x) x
#define BAD_CAST