mark strings extracted from PyArg_Parse* as "const"
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 21 Dec 2011 22:40:44 +0000 (17:40 -0500)
committerAles Kozumplik <akozumpl@redhat.com>
Thu, 22 Dec 2011 09:49:56 +0000 (10:49 +0100)
- Various places within the bindings use PyArg_ParseTuple[AndKeywords] to
  extract (char*) string arguments. These are pointers to the internal
  representation of a PyStringObject, and shouldn't be modified, hence
  it's safest to explicitly mark these values as (const char*), rather
  than just (char*).

Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
python/header-py.c
python/rpmfd-py.c
python/rpmmacro-py.c
python/rpmmi-py.c
python/rpmmodule.c
python/rpmts-py.c

index d312f54..2610344 100644 (file)
@@ -232,7 +232,7 @@ static PyObject * hdrFullFilelist(hdrObject * s)
 
 static PyObject * hdrFormat(hdrObject * s, PyObject * args, PyObject * kwds)
 {
-    char * fmt;
+    const char * fmt;
     char * r;
     errmsg_t err;
     PyObject * result;
@@ -859,7 +859,7 @@ static int compare_values(const char *str1, const char *str2)
 
 PyObject * labelCompare (PyObject * self, PyObject * args)
 {
-    char *v1, *r1, *v2, *r2;
+    const char *v1, *r1, *v2, *r2;
     const char *e1, *e2;
     int rc;
 
index 1150aa1..2d443f3 100644 (file)
@@ -57,8 +57,8 @@ static FD_t openPath(const char *path, const char *mode, const char *flags)
 static int rpmfd_init(rpmfdObject *s, PyObject *args, PyObject *kwds)
 {
     char *kwlist[] = { "obj", "mode", "flags", NULL };
-    char *mode = "r";
-    char *flags = "ufdio";
+    const char *mode = "r";
+    const char *flags = "ufdio";
     PyObject *fo = NULL;
     FD_t fd = NULL;
     int fdno;
index 074861d..3eb0acb 100644 (file)
@@ -7,7 +7,7 @@
 PyObject *
 rpmmacro_AddMacro(PyObject * self, PyObject * args, PyObject * kwds)
 {
-    char * name, * val;
+    const char * name, * val;
     char * kwlist[] = {"name", "value", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss:AddMacro", kwlist,
@@ -22,7 +22,7 @@ rpmmacro_AddMacro(PyObject * self, PyObject * args, PyObject * kwds)
 PyObject *
 rpmmacro_DelMacro(PyObject * self, PyObject * args, PyObject * kwds)
 {
-    char * name;
+    const char * name;
     char * kwlist[] = {"name", NULL};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:DelMacro", kwlist, &name))
@@ -36,7 +36,7 @@ rpmmacro_DelMacro(PyObject * self, PyObject * args, PyObject * kwds)
 PyObject * 
 rpmmacro_ExpandMacro(PyObject * self, PyObject * args, PyObject * kwds)
 {
-    char *macro;
+    const char *macro;
     PyObject *res;
     int num = 0;
     char * kwlist[] = {"macro", "numeric", NULL};
index 91eb21c..977e475 100644 (file)
@@ -99,7 +99,7 @@ static PyObject *
 rpmmi_Pattern(rpmmiObject * s, PyObject * args, PyObject * kwds)
 {
     int type;
-    char * pattern;
+    const char * pattern;
     rpmTagVal tag;
     char * kwlist[] = {"tag", "type", "patern", NULL};
 
index f9149cb..f2e0ed7 100644 (file)
@@ -28,7 +28,7 @@ PyObject * pyrpmError;
 
 static PyObject * archScore(PyObject * self, PyObject * arg)
 {
-    char * arch;
+    const char * arch;
 
     if (!PyArg_Parse(arg, "s", &arch))
        return NULL;
@@ -117,7 +117,7 @@ static PyObject * doLog(PyObject * self, PyObject * args, PyObject *kwds)
 
 static PyObject * reloadConfig(PyObject * self, PyObject * args, PyObject *kwds)
 {
-    char * target = NULL;
+    const char * target = NULL;
     char * kwlist[] = { "target", NULL };
     int rc;
     
index 854d3a1..5c6e9ba 100644 (file)
@@ -751,7 +751,7 @@ static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kw
 
 static int rpmts_init(rpmtsObject *s, PyObject *args, PyObject *kwds)
 {
-    char * rootDir = "/";
+    const char * rootDir = "/";
     rpmVSFlags vsflags = rpmExpandNumeric("%{?__vsflags}");
     char * kwlist[] = {"rootdir", "vsflags", 0};