python: Use Cython's libc.errno for EEXIST.
authorW. Trevor King <wking@tremily.us>
Fri, 19 Oct 2012 04:50:21 +0000 (00:50 -0400)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 25 Mar 2014 03:34:15 +0000 (00:34 -0300)
libkmod/python/kmod/_libkmod_h.pxd
libkmod/python/kmod/module.pyx

index ef948dd..0153ac0 100644 (file)
@@ -18,10 +18,6 @@ cdef extern from *:
     ctypedef void* const_void_ptr 'const void *'
 
 
-cdef extern from 'errno.h':
-    enum: EEXIST
-
-
 cdef extern from 'stdbool.h':
     ctypedef struct bool:
         pass
index 379a75d..7c84eb8 100644 (file)
@@ -9,6 +9,8 @@
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+cimport libc.errno as _errno
+
 cimport _libkmod_h
 from error import KmodError as _KmodError
 cimport list as _list
@@ -103,7 +105,7 @@ cdef class Module (object):
         # TODO: convert callbacks and data from Python object to C types
         err = _libkmod_h.kmod_module_probe_insert_module(
             self.module, flags, opt, install, d, print_action)
-        if err == -_libkmod_h.EEXIST:
+        if err == -_errno.EEXIST:
             raise _KmodError('Module already loaded')
         elif err < 0:
             raise _KmodError('Could not load module')