From: Kern Sibbald Date: Thu, 3 Jul 2008 10:31:20 +0000 (+0000) Subject: kes Fix python compiler string warning. Note, IMO the GNU C++ X-Git-Tag: Release-3.0.0~1195 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4715eed45b57fd37557fc0ccd65207c835d47080;p=bacula%2Fbacula 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. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7296 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/bdb.c b/bacula/src/cats/bdb.c index 2544192f16..b077a51934 100644 --- a/bacula/src/cats/bdb.c +++ b/bacula/src/cats/bdb.c @@ -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; diff --git a/bacula/src/dird/pythondir.c b/bacula/src/dird/pythondir.c index c8c9c463a9..241e79a3d3 100644 --- a/bacula/src/dird/pythondir.c +++ b/bacula/src/dird/pythondir.c @@ -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()) { diff --git a/bacula/src/filed/pythonfd.c b/bacula/src/filed/pythonfd.c index ccdca4b75d..42f9ce26b7 100644 --- a/bacula/src/filed/pythonfd.c +++ b/bacula/src/filed/pythonfd.c @@ -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()) { diff --git a/bacula/src/lib/pythonlib.c b/bacula/src/lib/pythonlib.c index bb1fb97949..329ce3abc1 100644 --- a/bacula/src/lib/pythonlib.c +++ b/bacula/src/lib/pythonlib.c @@ -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()) { diff --git a/bacula/src/stored/pythonsd.c b/bacula/src/stored/pythonsd.c index 95f4fef482..e52693d823 100644 --- a/bacula/src/stored/pythonsd.c +++ b/bacula/src/stored/pythonsd.c @@ -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()) { diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index c5ffe9d42b..e7fc045302 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -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.