Bunch of const char* corrections

- functions returning string constants as char * etc...
This commit is contained in:
Panu Matilainen 2007-12-14 15:17:59 +02:00
parent 7d817f06b1
commit 8d66d5fe4a
15 changed files with 33 additions and 29 deletions

View File

@ -920,7 +920,7 @@ static rpmRC parseForSimple(rpmSpec spec, Package pkg, char * buf,
} else {
/* XXX WATCHOUT: buf is an arg */
{
static char *_docdir_fmt= 0;
static const char *_docdir_fmt = NULL;
static int oneshot = 0;
const char *ddir, *fmt, *errstr;
if (!oneshot) {

View File

@ -256,7 +256,7 @@ static rpmRC processScriptFiles(rpmSpec spec, Package pkg)
} else {
/* This is dumb. When the header supports NULL string */
/* this will go away. */
char *bull = "";
const char *bull = "";
(void) headerAddOrAppendEntry(pkg->header, RPMTAG_TRIGGERSCRIPTS,
RPM_STRING_ARRAY_TYPE, &bull, 1);
}

View File

@ -41,11 +41,13 @@ void addChangelogEntry(Header h, time_t time, const char *name, const char *text
static int dateToTimet(const char * datestr, time_t * secs)
{
struct tm time;
char * p, * pe, * q, ** idx;
const char ** idx;
char * p, * pe, * q;
char * date = strcpy(alloca(strlen(datestr) + 1), datestr);
static char * days[] =
static const char * days[] =
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL };
static char * months[] =
static const char * months[] =
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL };
static char lengths[] =

View File

@ -73,7 +73,7 @@ int parseScript(rpmSpec spec, int parsePart)
char *p;
const char **progArgv = NULL;
int progArgc;
char *partname = NULL;
const char *partname = NULL;
rpm_tag_t reqtag = 0;
rpm_tag_t tag = 0;
int tagflags = 0;

View File

@ -246,7 +246,7 @@ int addSource(rpmSpec spec, Package pkg, const char *field, rpm_tag_t tag)
{
struct Source *p;
int flag = 0;
char *name = NULL;
const char *name = NULL;
char *nump;
const char *fieldp = NULL;
char buf[BUFSIZ];

View File

@ -177,17 +177,18 @@ int cpioHeaderRead(FSM_t fsm, struct stat * st)
const char * cpioStrerror(int rc)
{
static char msg[256];
char *s;
const char *s;
int myerrno = errno;
size_t l;
strcpy(msg, "cpio: ");
switch (rc) {
default:
s = msg + strlen(msg);
sprintf(s, _("(error 0x%x)"), (unsigned)rc);
default: {
char *t = msg + strlen(msg);
sprintf(t, _("(error 0x%x)"), (unsigned)rc);
s = NULL;
break;
}
case CPIOERR_BAD_MAGIC: s = _("Bad magic"); break;
case CPIOERR_BAD_HEADER: s = _("Bad/unreadable header");break;

View File

@ -127,7 +127,7 @@ static int yyerror(const char * s);
** An entry in the lexical lookup table.
*/
typedef struct _TABLE {
char *name;
const char *name;
int type;
time_t value;
} TABLE;

View File

@ -178,7 +178,7 @@ void providePackageNVR(Header h)
*/
if (!hge(h, RPMTAG_PROVIDEVERSION, &pvt, (void **) &providesEVR, NULL)) {
for (i = 0; i < providesCount; i++) {
char * vdummy = "";
const char * vdummy = "";
int32_t fdummy = RPMSENSE_ANY;
xx = headerAddOrAppendEntry(h, RPMTAG_PROVIDEVERSION, RPM_STRING_ARRAY_TYPE,
&vdummy, 1);

View File

@ -400,7 +400,7 @@ exit:
return rpmrc;
}
static char * SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin";
static const char * SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin";
/**
* Return scriptlet name from tag.

View File

@ -697,7 +697,7 @@ static rpmRC doReadRC( FD_t fd, const char * urlfn)
*/
static rpmRC rpmPlatform(const char * platform)
{
char *cpu = NULL, *vendor = NULL, *os = NULL, *gnu = NULL;
const char *cpu = NULL, *vendor = NULL, *os = NULL, *gnu = NULL;
uint8_t * b = NULL;
ssize_t blen = 0;
int init_platform = 0;

View File

@ -725,7 +725,7 @@ PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args, PyObject * kwds)
FD_t fd;
int fileno;
PyObject * list;
char * kwlist[] = {"fd", NULL};
const char * kwlist[] = {"fd", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &fileno))
return NULL;
@ -929,7 +929,8 @@ static int compare_values(const char *str1, const char *str2)
PyObject * labelCompare (PyObject * self, PyObject * args)
{
char *v1, *r1, *e1, *v2, *r2, *e2;
char *v1, *r1, *v2, *r2;
const char *e1, *e2;
int rc;
if (!PyArg_ParseTuple(args, "(zzz)(zzz)",

View File

@ -36,7 +36,7 @@ void headerDump(Header h, FILE *f, int flags,
indexEntry p;
const struct headerTagTableEntry_s * tage;
const char * tag;
char * type;
const char * type;
/* First write out the length of the index (count of index entries) */
fprintf(f, "Entry count: %d\n", h->indexUsed);

View File

@ -109,7 +109,7 @@ static char * lastGname = NULL;
return 0;
}
char * uidToUname(uid_t uid)
const char * uidToUname(uid_t uid)
{
static uid_t lastUid = (uid_t) -1;
static char * lastUname = NULL;
@ -140,7 +140,7 @@ static char * lastUname = NULL;
}
}
char * gidToGname(gid_t gid)
const char * gidToGname(gid_t gid)
{
static gid_t lastGid = (gid_t) -1;
static char * lastGname = NULL;

View File

@ -19,8 +19,8 @@ int gnameToGid(const char * thisGname, gid_t * gid);
/*
* Call w/ -1 to flush the cache, returns NULL if the user can't be found.
*/
char * uidToUname(uid_t uid);
char * gidToGname(gid_t gid);
const char * uidToUname(uid_t uid);
const char * gidToGname(gid_t gid);
#ifdef __cplusplus
}

View File

@ -84,10 +84,10 @@ typedef struct {
/*---------Global Variables, in all caps---------*/
/*name of this program*/
char *PROGRAM_NAME=0;
const char *PROGRAM_NAME=0;
/*name of the current class file*/
char *FILE_NAME=0;
const char *FILE_NAME=0;
/*the name of the last class file seen*/
char *CLASS_NAME=0;
@ -139,10 +139,10 @@ int SIZE_PRINT_TABLE;
void usage (void);
void outofmemory(void);
void die(char *format, ...);
void die(const char *format, ...);
size_t my_fread(void *ptr, size_t size, size_t nitems, FILE *stream);
void check_range(short entryNum, short value, short poolSize);
char *is_lower_equal (char *string, char *pattern);
char *is_lower_equal (char *string, const char *pattern);
int findJavaMagic (FILE *fileHandle);
int my_strcmp (const void *a, const void *b);
void print_table_flush(void);
@ -292,7 +292,7 @@ void outofmemory(void) {
}
void die(char *format, ...) {
void die(const char *format, ...) {
/* Most errors are fatal.
This function throws a fatal error and
accepts arguments like printf does*/
@ -389,7 +389,7 @@ void check_range(short entryNum, short value, short poolSize) {
prefix of my strings. */
char
*is_lower_equal (char *string, char *pattern)
*is_lower_equal (char *string, const char *pattern)
{
while ( (tolower(*string) == *pattern) &&
@ -1157,7 +1157,7 @@ void processJavaFile (FILE *fileHandle) {
CLASS_NAME=findClassName(fileHandle, &symbolTable);
if(ARG_DEPSFORMAT) {
char *prefix_seperator = ": ";
const char *prefix_seperator = ": ";
format_class_name = formatClassName(CLASS_NAME, '\0', 0);