Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 576837 Details for
Bug 790973
[PATCHES] Bugs found in python-krbV-1.0.90-4.fc15 using gcc-with-cpychecker static analyzer
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
[PATCH 5/5] introduce make_class helper function
0005-introduce-make_class-helper-function.patch (text/plain), 9.52 KB, created by
Dave Malcolm
on 2012-04-11 18:31:40 UTC
(
hide
)
Description:
[PATCH 5/5] introduce make_class helper function
Filename:
MIME Type:
Creator:
Dave Malcolm
Created:
2012-04-11 18:31:40 UTC
Size:
9.52 KB
patch
obsolete
>From 81e045e4f23abd7b49f7ebebc4400cc345c2a02b Mon Sep 17 00:00:00 2001 >From: David Malcolm <dmalcolm@redhat.com> >Date: Wed, 11 Apr 2012 14:25:07 -0400 >Subject: [PATCH 5/5] introduce make_class helper function > >introduce make_class helper function and use it to replace the copy-and-pasted >insides of all of the various pk_*_make_class functions >--- > krb5module.c | 194 ++++++++++++++++++--------------------------------------- > 1 files changed, 61 insertions(+), 133 deletions(-) > >diff --git a/krb5module.c b/krb5module.c >index d0cd7be..507d642 100644 >--- a/krb5module.c >+++ b/krb5module.c >@@ -140,6 +140,41 @@ Keytab_get_krb5_keytab(PyObject *self) > return NULL; > } > >+static PyObject * >+make_class(PyObject *module, >+ const char *name, >+ PyMethodDef methods[], >+ PyMethodDef *getattr, >+ PyMethodDef *setattr) >+{ >+ PyMethodDef *def; >+ PyObject *dict; >+ PyObject *nameobj; >+ PyObject *retval; >+ PyClassObject *klass; >+ >+ dict = PyDict_New(); >+ nameobj = PyString_FromString(name); >+ >+ retval = PyClass_New(NULL, dict, nameobj); >+ klass = (PyClassObject *)retval; >+ >+ PyObject_SetAttrString(retval, "__module__", module); >+ >+ for(def = methods; def->ml_name; def++) >+ { >+ PyObject *func = PyCFunction_New(def, NULL); >+ PyObject *method = PyMethod_New(func, NULL, retval); >+ PyDict_SetItemString(dict, def->ml_name, method); >+ Py_DECREF(func); >+ Py_DECREF(method); >+ } >+ klass->cl_getattr = PyMethod_New(PyCFunction_New(getattr, NULL), NULL, retval); >+ klass->cl_setattr = PyMethod_New(PyCFunction_New(setattr, NULL), NULL, retval); >+ >+ return retval; >+} >+ > PyDoc_STRVAR(Context_init__doc__, > "__init__() -> KrbV.Context \n\ > \n\ >@@ -1581,31 +1616,15 @@ static PyMethodDef context_methods[] = { > static PyObject * > pk_context_make_class(PyObject *module) > { >- PyMethodDef *def; > static PyMethodDef > getattr = {"__getattr__", Context_getattr, METH_VARARGS, Context_getattr__doc__}, > setattr = {"__setattr__", Context_setattr, METH_VARARGS, Context_setattr__doc__}; >- PyObject *dict, *name, *retval; >- PyClassObject *klass; >- dict = PyDict_New(); >- name = PyString_FromString("Context"); >- >- retval = PyClass_New(NULL, dict, name); >- klass = (PyClassObject *)retval; >- >- PyObject_SetAttrString(retval, "__module__", module); >- for(def = context_methods; def->ml_name; def++) >- { >- PyObject *func = PyCFunction_New(def, NULL); >- PyObject *method = PyMethod_New(func, NULL, retval); >- PyDict_SetItemString(dict, def->ml_name, method); >- Py_DECREF(func); >- Py_DECREF(method); >- } >- klass->cl_getattr = PyMethod_New(PyCFunction_New(&getattr, NULL), NULL, retval); >- klass->cl_setattr = PyMethod_New(PyCFunction_New(&setattr, NULL), NULL, retval); > >- return retval; >+ return make_class(module, >+ "Context", >+ context_methods, >+ &getattr, >+ &setattr); > } > > /* Convert a string representation of an address to a krb5_address */ >@@ -2156,33 +2175,15 @@ static PyMethodDef auth_context_methods[] = { > static PyObject * > pk_auth_context_make_class(PyObject *module) > { >- PyMethodDef *def; > static PyMethodDef > getattr = {"__getattr__", AuthContext_getattr, METH_VARARGS, AuthContext_getattr__doc__}, > setattr = {"__setattr__", AuthContext_setattr, METH_VARARGS, AuthContext_setattr__doc__}; >- PyObject *dict, *name, *retval; >- PyClassObject *klass; >- >- dict = PyDict_New(); >- name = PyString_FromString("AuthContext"); >- >- retval = PyClass_New(NULL, dict, name); >- klass = (PyClassObject *)retval; >- >- PyObject_SetAttrString(retval, "__module__", module); >- for(def = auth_context_methods; def->ml_name; def++) >- { >- PyObject *func = PyCFunction_New(def, NULL); >- PyObject *method = PyMethod_New(func, NULL, retval); >- PyDict_SetItemString(dict, def->ml_name, method); >- Py_DECREF(func); >- Py_DECREF(method); >- } > >- klass->cl_getattr = PyMethod_New(PyCFunction_New(&getattr, NULL), NULL, retval); >- klass->cl_setattr = PyMethod_New(PyCFunction_New(&setattr, NULL), NULL, retval); >- >- return retval; >+ return make_class(module, >+ "AuthContext", >+ auth_context_methods, >+ &getattr, >+ &setattr); > } > > /************************* Principal **********************************/ >@@ -2579,32 +2580,15 @@ static PyMethodDef principal_methods[] = { > static PyObject * > pk_principal_make_class(PyObject *module) > { >- PyMethodDef *def; > static PyMethodDef > getattr = {"__getattr__", Principal_getattr, METH_VARARGS, Principal_getattr__doc__}, > setattr = {"__setattr__", Principal_setattr, METH_VARARGS, Principal_setattr__doc__}; >- PyObject *dict, *name, *retval; >- PyClassObject *klass; >- >- dict = PyDict_New(); >- name = PyString_FromString("Principal"); >- >- retval = PyClass_New(NULL, dict, name); >- klass = (PyClassObject *)retval; > >- PyObject_SetAttrString(retval, "__module__", module); >- for(def = principal_methods; def->ml_name; def++) >- { >- PyObject *func = PyCFunction_New(def, NULL); >- PyObject *method = PyMethod_New(func, NULL, retval); >- PyDict_SetItemString(dict, def->ml_name, method); >- Py_DECREF(func); >- Py_DECREF(method); >- } >- klass->cl_getattr = PyMethod_New(PyCFunction_New(&getattr, NULL), NULL, retval); >- klass->cl_setattr = PyMethod_New(PyCFunction_New(&setattr, NULL), NULL, retval); >- >- return retval; >+ return make_class(module, >+ "Principal", >+ principal_methods, >+ &getattr, >+ &setattr); > } > > /************************* Creds cache **********************************/ >@@ -3252,32 +3236,11 @@ static PyMethodDef ccache_methods[] = { > static PyObject * > pk_ccache_make_class(PyObject *module) > { >- PyMethodDef *def; > static PyMethodDef > getattr = {"__getattr__", CCache_getattr, METH_VARARGS, CCache_getattr__doc__}, > setattr = {"__setattr__", CCache_setattr, METH_VARARGS, CCache_setattr__doc__}; >- PyObject *dict, *name, *retval; >- PyClassObject *klass; >- >- dict = PyDict_New(); >- name = PyString_FromString("CCache"); > >- retval = PyClass_New(NULL, dict, name); >- klass = (PyClassObject *)retval; >- >- PyObject_SetAttrString(retval, "__module__", module); >- for(def = ccache_methods; def->ml_name; def++) >- { >- PyObject *func = PyCFunction_New(def, NULL); >- PyObject *method = PyMethod_New(func, NULL, retval); >- PyDict_SetItemString(dict, def->ml_name, method); >- Py_DECREF(func); >- Py_DECREF(method); >- } >- klass->cl_getattr = PyMethod_New(PyCFunction_New(&getattr, NULL), NULL, retval); >- klass->cl_setattr = PyMethod_New(PyCFunction_New(&setattr, NULL), NULL, retval); >- >- return retval; >+ return make_class(module, "CCache", ccache_methods, &getattr, &setattr); > } > > /************************* replay cache **********************************/ >@@ -3469,32 +3432,15 @@ static PyMethodDef rcache_methods[] = { > static PyObject * > pk_rcache_make_class(PyObject *module) > { >- PyMethodDef *def; > static PyMethodDef > getattr = {"__getattr__", RCache_getattr, METH_VARARGS, RCache_getattr__doc__}, > setattr = {"__setattr__", RCache_setattr, METH_VARARGS, RCache_setattr__doc__}; >- PyObject *dict, *name, *retval; >- PyClassObject *klass; >- >- dict = PyDict_New(); >- name = PyString_FromString("RCache"); >- >- retval = PyClass_New(NULL, dict, name); >- klass = (PyClassObject *)retval; > >- PyObject_SetAttrString(retval, "__module__", module); >- for(def = rcache_methods; def->ml_name; def++) >- { >- PyObject *func = PyCFunction_New(def, NULL); >- PyObject *method = PyMethod_New(func, NULL, retval); >- PyDict_SetItemString(dict, def->ml_name, method); >- Py_DECREF(func); >- Py_DECREF(method); >- } >- klass->cl_getattr = PyMethod_New(PyCFunction_New(&getattr, NULL), NULL, retval); >- klass->cl_setattr = PyMethod_New(PyCFunction_New(&setattr, NULL), NULL, retval); >- >- return retval; >+ return make_class(module, >+ "RCache", >+ rcache_methods, >+ &getattr, >+ &setattr); > } > > /************************* keytab **********************************/ >@@ -3743,32 +3689,14 @@ static PyMethodDef keytab_methods[] = { > static PyObject * > pk_keytab_make_class(PyObject *module) > { >- PyMethodDef *def; > static PyMethodDef > getattr = {"__getattr__", Keytab_getattr, METH_VARARGS, Keytab_getattr__doc__}, > setattr = {"__setattr__", Keytab_setattr, METH_VARARGS, Keytab_setattr__doc__}; >- PyObject *dict, *name, *retval; >- PyClassObject *klass; >- >- dict = PyDict_New(); >- name = PyString_FromString("Keytab"); >- >- retval = PyClass_New(NULL, dict, name); >- klass = (PyClassObject *)retval; >- >- PyObject_SetAttrString(retval, "__module__", module); >- for(def = keytab_methods; def->ml_name; def++) >- { >- PyObject *func = PyCFunction_New(def, NULL); >- PyObject *method = PyMethod_New(func, NULL, retval); >- PyDict_SetItemString(dict, def->ml_name, method); >- Py_DECREF(func); >- Py_DECREF(method); >- } >- klass->cl_getattr = PyMethod_New(PyCFunction_New(&getattr, NULL), NULL, retval); >- klass->cl_setattr = PyMethod_New(PyCFunction_New(&setattr, NULL), NULL, retval); >- >- return retval; >+ return make_class(module, >+ "Keytab", >+ keytab_methods, >+ &getattr, >+ &setattr); > } /* pk_keytab_make_class() */ > > /****** main module ********/ >-- >1.7.6.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 790973
:
576833
|
576834
|
576835
|
576836
| 576837