]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Fix python compiler string warning. Note, IMO the GNU C++
authorKern Sibbald <kern@sibbald.com>
Thu, 3 Jul 2008 10:31:20 +0000 (10:31 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 3 Jul 2008 10:31:20 +0000 (10:31 +0000)
     compiler guys have made a *very* bad change to their compiler.
     They now force all strings to be 'const' unless you explicitly
     cast them, which is extremely ugly and ruins nice code as well
     as creates a lot of useless work.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7296 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/bdb.c
bacula/src/dird/pythondir.c
bacula/src/filed/pythonfd.c
bacula/src/lib/pythonlib.c
bacula/src/stored/pythonsd.c
bacula/technotes-2.5

index 2544192f16af33dd8b8deedd144e161105e9e615..b077a5193441cdd222e45712ba6c6f736a77b125 100644 (file)
@@ -98,7 +98,7 @@ dbid_list::~dbid_list()
    free(DBId);
 }
 
-static POOLMEM *make_filename(B_DB *mdb, char *name)
+static POOLMEM *make_filename(B_DB *mdb, const char *name)
 {
    char sep;
    POOLMEM *dbf;
index c8c9c463a9ed7d7cb61f3ca7dffcb592ae593827..241e79a3d3f9a0e30116c928b94fdc66ee4e4c8d 100644 (file)
@@ -138,78 +138,78 @@ PyObject *job_getattr(PyObject *self, char *attrname)
    }
    switch (i) {
    case 0:                            /* Job */
-      return Py_BuildValue(getvars[i].fmt, jcr->job->hdr.name);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->job->hdr.name);
    case 1:                            /* level */
-      return Py_BuildValue(getvars[i].fmt, job_level_to_str(jcr->JobLevel));
+      return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->JobLevel));
    case 2:                            /* type */
-      return Py_BuildValue(getvars[i].fmt, job_type_to_str(jcr->JobType));
+      return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->JobType));
    case 3:                            /* JobId */
-      return Py_BuildValue(getvars[i].fmt, jcr->JobId);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->JobId);
    case 4:                            /* Client */
-      return Py_BuildValue(getvars[i].fmt, jcr->client->hdr.name);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->client->hdr.name);
    case 5:                            /* NumVols */
       POOL_DBR pr;
       memset(&pr, 0, sizeof(pr));
       bstrncpy(pr.Name, jcr->pool->hdr.name, sizeof(pr.Name));
       if (db_get_pool_record(jcr, jcr->db, &pr)) {
          jcr->NumVols = pr.NumVols;
-         return Py_BuildValue(getvars[i].fmt, jcr->NumVols);
+         return Py_BuildValue((char *)getvars[i].fmt, jcr->NumVols);
       } else {
          bsnprintf(errmsg, sizeof(errmsg), _("Pool record not found."));
          goto bail_out;
       }
    case 6:                            /* Pool */
-      return Py_BuildValue(getvars[i].fmt, jcr->pool->name());
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->pool->name());
    case 7:                            /* Storage */
       if (jcr->wstore) {
-         return Py_BuildValue(getvars[i].fmt, jcr->wstore->name());
+         return Py_BuildValue((char *)getvars[i].fmt, jcr->wstore->name());
       } else if (jcr->rstore) {
-         return Py_BuildValue(getvars[i].fmt, jcr->rstore->name());
+         return Py_BuildValue((char *)getvars[i].fmt, jcr->rstore->name());
       } else {
          goto bail_out;
       }
    case 8:
-      return Py_BuildValue(getvars[i].fmt, jcr->catalog->name());
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->catalog->name());
    case  9:                           /* MediaType */
       if (jcr->wstore) {
-         return Py_BuildValue(getvars[i].fmt, jcr->wstore->media_type);
+         return Py_BuildValue((char *)getvars[i].fmt, jcr->wstore->media_type);
       } else if (jcr->rstore) {
-         return Py_BuildValue(getvars[i].fmt, jcr->rstore->media_type);
+         return Py_BuildValue((char *)getvars[i].fmt, jcr->rstore->media_type);
       } else {
          goto bail_out;
       }
    case 10:                           /* JobName */
-      return Py_BuildValue(getvars[i].fmt, jcr->Job);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->Job);
    case 11:                           /* JobStatus */
       buf[1] = 0;
       buf[0] = jcr->JobStatus;
-      return Py_BuildValue(getvars[i].fmt, buf);
+      return Py_BuildValue((char *)getvars[i].fmt, buf);
    case 12:                           /* Priority */
-      return Py_BuildValue(getvars[i].fmt, jcr->JobPriority);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->JobPriority);
    case 13:
-      return Py_BuildValue(getvars[i].fmt, jcr->VolumeName);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->VolumeName);
    case 14:                           /* CatalogRes */
-      return Py_BuildValue(getvars[i].fmt,
+      return Py_BuildValue((char *)getvars[i].fmt,
          jcr->catalog->db_name, jcr->catalog->db_address, 
          jcr->catalog->db_user, jcr->catalog->db_password,
          jcr->catalog->db_socket, jcr->catalog->db_port,
          db_get_type());
    case 15:                           /* JobErrors */
-      return Py_BuildValue(getvars[i].fmt, jcr->JobErrors);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->JobErrors);
    case 16:                           /* JobFiles */
-      return Py_BuildValue(getvars[i].fmt, jcr->JobFiles);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->JobFiles);
    case 17:                           /* SDJobFiles */
-      return Py_BuildValue(getvars[i].fmt, jcr->SDJobFiles);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->SDJobFiles);
    case 18:                           /* SDErrors */
-      return Py_BuildValue(getvars[i].fmt, jcr->SDErrors);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->SDErrors);
    case 19:                           /* FDJobStatus */
       buf[1] = 0;
       buf[0] = jcr->FDJobStatus;
-      return Py_BuildValue(getvars[i].fmt, buf);
+      return Py_BuildValue((char *)getvars[i].fmt, buf);
    case 29:                           /* SDJobStatus */
       buf[1] = 0;
       buf[0] = jcr->SDJobStatus;
-      return Py_BuildValue(getvars[i].fmt, buf);
+      return Py_BuildValue((char *)getvars[i].fmt, buf);
    }
    bsnprintf(errmsg, sizeof(errmsg), _("Attribute %s not found."), attrname);
 bail_out:
@@ -253,13 +253,13 @@ int job_setattr(PyObject *self, char *attrname, PyObject *value)
    if (setvars[i].fmt != NULL) {
       switch (setvars[i].fmt[0]) {
       case 's':
-         if (!PyArg_Parse(value, setvars[i].fmt, &strval)) {
+         if (!PyArg_Parse(value, (char *)setvars[i].fmt, &strval)) {
             PyErr_SetString(PyExc_TypeError, _("Read-only attribute"));
             return -1;
          }
          break;
       case 'i':
-         if (!PyArg_Parse(value, setvars[i].fmt, &intval)) {
+         if (!PyArg_Parse(value, (char *)setvars[i].fmt, &intval)) {
             PyErr_SetString(PyExc_TypeError, _("Read-only attribute"));
             return -1;
          }
@@ -459,7 +459,7 @@ int generate_job_event(JCR *jcr, const char *event)
    }
 
    bstrncpy(jcr->event, event, sizeof(jcr->event));
-   result = PyObject_CallFunction(method, "O", Job);
+   result = PyObject_CallFunction(method, (char *)"O", Job);
    jcr->event[0] = 0;             /* no event in progress */
    if (result == NULL) {
       if (PyErr_Occurred()) {
index ccdca4b75ddf7aa3283c0b797aff055fac102e4d..42f9ce26b71426ef45ba6f8cb64a7eec3d377f8a 100644 (file)
@@ -109,21 +109,21 @@ PyObject *job_getattr(PyObject *self, char *attrname)
    }
    switch (i) {
    case 0:                            /* FD's name */
-      return Py_BuildValue(getvars[i].fmt, my_name);
+      return Py_BuildValue((char *)getvars[i].fmt, my_name);
    case 1:                            /* level */
-      return Py_BuildValue(getvars[i].fmt, job_level_to_str(jcr->JobLevel));
+      return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->JobLevel));
    case 2:                            /* type */
-      return Py_BuildValue(getvars[i].fmt, job_type_to_str(jcr->JobType));
+      return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->JobType));
    case 3:                            /* JobId */
-      return Py_BuildValue(getvars[i].fmt, jcr->JobId);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->JobId);
    case 4:                            /* Client */
-      return Py_BuildValue(getvars[i].fmt, jcr->client_name);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->client_name);
    case 5:                            /* JobName */
-      return Py_BuildValue(getvars[i].fmt, jcr->Job);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->Job);
    case 6:                            /* JobStatus */
       buf[1] = 0;
       buf[0] = jcr->JobStatus;
-      return Py_BuildValue(getvars[i].fmt, buf);
+      return Py_BuildValue((char *)getvars[i].fmt, buf);
    }
    bsnprintf(errmsg, sizeof(errmsg), _("Attribute %s not found."), attrname);
 bail_out:
@@ -166,7 +166,7 @@ int job_setattr(PyObject *self, char *attrname, PyObject *value)
    }
    /* Get argument value ***FIXME*** handle other formats */
    if (setvars[i].fmt != NULL) {
-      if (!PyArg_Parse(value, setvars[i].fmt, &strval)) {
+      if (!PyArg_Parse(value, (char *)setvars[i].fmt, &strval)) {
          PyErr_SetString(PyExc_TypeError, _("Read-only attribute"));
          return -1;
       }
@@ -245,7 +245,7 @@ int generate_job_event(JCR *jcr, const char *event)
    }
 
    bstrncpy(jcr->event, event, sizeof(jcr->event));
-   result = PyObject_CallFunction(method, "O", Job);
+   result = PyObject_CallFunction(method, (char *)"O", Job);
    jcr->event[0] = 0;             /* no event in progress */
    if (result == NULL) {
       if (PyErr_Occurred()) {
index bb1fb97949e4709e42f7113c0e7388a8dfe2fe48..329ce3abc13d2d2c0744bd1685633cbdc992fdfc 100644 (file)
@@ -232,6 +232,7 @@ int generate_daemon_event(JCR *jcr, const char *event)
    PyObject *pJob;
    int stat = -1;
    PyObject *result = NULL;
+   char *obj_fmt = (char *)"O";
 
    if (!StartUp_module) {
       Dmsg0(100, "No startup module.\n");
@@ -254,7 +255,7 @@ int generate_daemon_event(JCR *jcr, const char *event)
       }
       ((JobObject *)pJob)->jcr = jcr;
       bstrncpy(jcr->event, event, sizeof(jcr->event));
-      result = PyObject_CallFunction(JobStart_method, "O", pJob);
+      result = PyObject_CallFunction(JobStart_method, obj_fmt, pJob);
       jcr->event[0] = 0;             /* no event in progress */
       if (result == NULL) {
          JobStart_method = NULL;
@@ -277,7 +278,7 @@ int generate_daemon_event(JCR *jcr, const char *event)
       }
       bstrncpy(jcr->event, event, sizeof(jcr->event));
       Dmsg1(100, "Call daemon event=%s\n", event);
-      result = PyObject_CallFunction(JobEnd_method, "O", jcr->Python_job);
+      result = PyObject_CallFunction(JobEnd_method, obj_fmt, jcr->Python_job);
       jcr->event[0] = 0;             /* no event in progress */
       if (result == NULL) {
          if (PyErr_Occurred()) {
index 95f4fef482c113b00fdbcdc57cdb49fb78440a3a..e52693d8233b4ed18b6c182a800b78856fe4bf3b 100644 (file)
@@ -116,31 +116,31 @@ PyObject *job_getattr(PyObject *self, char *attrname)
    }  
    switch (i) {
    case 0:                            /* Job */
-      return Py_BuildValue(getvars[i].fmt, jcr->job_name);    /* Non-unique name */
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->job_name);    /* Non-unique name */
    case 1:                            /* SD's name */
-      return Py_BuildValue(getvars[i].fmt, my_name);
+      return Py_BuildValue((char *)getvars[i].fmt, my_name);
    case 2:                            /* level */
-      return Py_BuildValue(getvars[i].fmt, job_level_to_str(jcr->JobLevel));
+      return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->JobLevel));
    case 3:                            /* type */
-      return Py_BuildValue(getvars[i].fmt, job_type_to_str(jcr->JobType));
+      return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->JobType));
    case 4:                            /* JobId */
-      return Py_BuildValue(getvars[i].fmt, jcr->JobId);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->JobId);
    case 5:                            /* Client */
-      return Py_BuildValue(getvars[i].fmt, jcr->client_name);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->client_name);
    case 6:                            /* Pool */
-      return Py_BuildValue(getvars[i].fmt, jcr->dcr->pool_name);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->dcr->pool_name);
    case 7:                            /* MediaType */
-      return Py_BuildValue(getvars[i].fmt, jcr->dcr->media_type);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->dcr->media_type);
    case 8:                            /* JobName */
-      return Py_BuildValue(getvars[i].fmt, jcr->Job);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->Job);
    case 9:                            /* JobStatus */
       buf[1] = 0;
       buf[0] = jcr->JobStatus;
-      return Py_BuildValue(getvars[i].fmt, buf);
+      return Py_BuildValue((char *)getvars[i].fmt, buf);
    case 10:
-      return Py_BuildValue(getvars[i].fmt, jcr->dcr->VolumeName);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->dcr->VolumeName);
    case 11:
-      return Py_BuildValue(getvars[i].fmt, jcr->dcr->dev_name);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->dcr->dev_name);
    }
    bsnprintf(errmsg, sizeof(errmsg), _("Attribute %s not found."), attrname);
 bail_out:
@@ -181,7 +181,7 @@ int job_setattr(PyObject *self, char *attrname, PyObject *value)
    }
    /* Get argument value ***FIXME*** handle other formats */
    if (setvars[i].fmt != NULL) {
-      if (!PyArg_Parse(value, setvars[i].fmt, &strval)) {
+      if (!PyArg_Parse(value, (char *)setvars[i].fmt, &strval)) {
          PyErr_SetString(PyExc_TypeError, _("Read-only attribute"));
          return -1;
       }
@@ -255,7 +255,7 @@ int generate_job_event(JCR *jcr, const char *event)
    }
 
    bstrncpy(jcr->event, event, sizeof(jcr->event));
-   result = PyObject_CallFunction(method, "O", Job);
+   result = PyObject_CallFunction(method, (char *)"O", Job);
    jcr->event[0] = 0;             /* no event in progress */
    if (result == NULL) {
       if (PyErr_Occurred()) {
index c5ffe9d42b1929d7e7edacbde59301d0051e7973..e7fc04530287c831acafd42e48731e0a867178c9 100644 (file)
@@ -30,6 +30,12 @@ vtape driver
 
 
 General:
+03Jul08
+kes  Fix python compiler string warning. Note, IMO the GNU C++ 
+     compiler guys have made a *very* bad change to their compiler.
+     They now force all strings to be 'const' unless you explicitly
+     cast them, which is extremely ugly and ruins nice code as well
+     as creates a lot of useless work.
 02Jul08
 kes  Fix mtx-changer to detect both versions of Ubuntu (Debian)
      mt. This fixes bug #1116.