Author: Lisandro Dalcin <[email protected]>
Branch:
Changeset: r1595:25bdcb810dc0
Date: 2014-11-24 21:31 +0300
http://bitbucket.org/cffi/cffi/changeset/25bdcb810dc0/
Log: Silence GCC/Clang -Wunused-parameter warnings
diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -65,7 +65,7 @@
# The following two 'chained_list_constants' items contains
# the head of these two chained lists, as a string that gives the
# call to do, if any.
- self._chained_list_constants = ['0', '0']
+ self._chained_list_constants = ['((void)lib,0)', '((void)lib,0)']
#
prnt = self._prnt
# first paste some standard set of lines that are mostly '#define'
@@ -337,7 +337,7 @@
prnt = self._prnt
numargs = len(tp.args)
if numargs == 0:
- argname = 'no_arg'
+ argname = 'noarg'
elif numargs == 1:
argname = 'arg0'
else:
@@ -387,6 +387,9 @@
prnt(' Py_END_ALLOW_THREADS')
prnt()
#
+ prnt(' (void)self; /* unused */')
+ if numargs == 0:
+ prnt(' (void)noarg; /* unused */')
if result_code:
prnt(' return %s;' %
self._convert_expr_from_c(tp.result, 'result', 'result type'))
@@ -453,6 +456,7 @@
prnt('static void %s(%s *p)' % (checkfuncname, cname))
prnt('{')
prnt(' /* only to generate compile-time warnings or errors */')
+ prnt(' (void)p;')
for fname, ftype, fbitsize in tp.enumfields():
if (isinstance(ftype, model.PrimitiveType)
and ftype.is_integer_type()) or fbitsize >= 0:
@@ -483,6 +487,8 @@
prnt(' sizeof(((%s *)0)->%s),' % (cname, fname))
prnt(' -1')
prnt(' };')
+ prnt(' (void)self; /* unused */')
+ prnt(' (void)noarg; /* unused */')
prnt(' return _cffi_get_struct_layout(nums);')
prnt(' /* the next line is not executed, but compiled */')
prnt(' %s(0);' % (checkfuncname,))
@@ -911,6 +917,7 @@
{
PyObject *library;
int was_alive = (_cffi_types != NULL);
+ (void)self; /* unused */
if (!PyArg_ParseTuple(args, "OOO", &_cffi_types, &_cffi_VerificationError,
&library))
return NULL;
diff --git a/cffi/vengine_gen.py b/cffi/vengine_gen.py
--- a/cffi/vengine_gen.py
+++ b/cffi/vengine_gen.py
@@ -235,6 +235,7 @@
prnt('static void %s(%s *p)' % (checkfuncname, cname))
prnt('{')
prnt(' /* only to generate compile-time warnings or errors */')
+ prnt(' (void)p;')
for fname, ftype, fbitsize in tp.enumfields():
if (isinstance(ftype, model.PrimitiveType)
and ftype.is_integer_type()) or fbitsize >= 0:
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -430,7 +430,7 @@
ffi = FFI()
ffi.cdef("typedef struct foo_s foo_t; int bar(foo_t *);")
lib = ffi.verify("typedef struct foo_s foo_t;\n"
- "int bar(foo_t *f) { return 42; }\n")
+ "int bar(foo_t *f) { (void)f; return 42; }\n")
assert lib.bar(ffi.NULL) == 42
def test_ffi_full_struct():
@@ -1810,7 +1810,7 @@
def test_typeof_function():
ffi = FFI()
ffi.cdef("int foo(int, char);")
- lib = ffi.verify("int foo(int x, char y) { return 42; }")
+ lib = ffi.verify("int foo(int x, char y) { (void)x; (void)y; return 42; }")
ctype = ffi.typeof(lib.foo)
assert len(ctype.args) == 2
assert ctype.result == ffi.typeof("int")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit