dtcm: Resolve 303 compiler warnings.

This commit is contained in:
Peter Howkins
2015-01-13 14:22:25 +00:00
parent fe39b630b3
commit 8baeb4c0a0
44 changed files with 275 additions and 250 deletions

View File

@@ -539,7 +539,7 @@ _DtCmsDoUpdateEntryCallback(
if (newid > 0)
sprintf(nbuf, "%ld", newid);
else
nbuf[0] = NULL;
nbuf[0] = '\0';
udata.newid = nbuf;
udata.scope = scope;
udata.time = time;

View File

@@ -292,7 +292,7 @@ _DtCmsSetFileVersion(_DtCmsCalendar *cal, int version)
if ((cal->types = (int *)calloc(1, sizeof(int) *
(_DtCm_entry_name_tbl->size + 1))) == NULL) {
_DtCmsFreeCalendar(cal);
return (NULL);
return (0);
} else
_DtCm_get_attribute_types(_DtCm_entry_name_tbl->size,
cal->types);
@@ -476,7 +476,7 @@ _DtCmsGetCalendarByName(char *target, boolean_t load, _DtCmsCalendar **cal)
_DtCmsCalendar *clist = calendar_list;
if ((name = get_calname(target)) == NULL)
return (NULL);
return (0);
while (clist != NULL) {
if (strcmp (name, clist->calendar) == 0) {
@@ -1033,7 +1033,7 @@ get_calname(char *target)
if (ptr == NULL) {
return (strdup(target));
} else {
*ptr = NULL;
*ptr = '\0';
name = strdup(target);
*ptr = '@';
return (name);

View File

@@ -1239,7 +1239,7 @@ _DtCmsCreateCallog(char *user, cms_create_args *args, _DtCmsCalendar **newcal)
/* use passed in char set if client does not supply one */
if (cal->attrs[CSA_CAL_ATTR_CHARACTER_SET_I].value == NULL &&
args->char_set && *args->char_set != NULL) {
args->char_set && *args->char_set != '\0') {
if ((stat = _DtCm_set_string_attrval(args->char_set,
&cal->attrs[CSA_CAL_ATTR_CHARACTER_SET_I].value,
CSA_VALUE_STRING)) != CSA_SUCCESS) {
@@ -1335,7 +1335,7 @@ _grow_char_array(void *ptr, uint oldcount, uint newcount)
void *nptr;
if (nptr = realloc(ptr, newcount)) {
memset((void *)((char *)nptr + oldcount), NULL,
memset((void *)((char *)nptr + oldcount), 0,
newcount - oldcount);
return (nptr);
} else

View File

@@ -112,7 +112,7 @@ static u_int sendit_value[255];
#define TVAL(a,b) { #a,-1, -1, &externTag.tag,b,TAGSVAL }
#define SVAL(a,b) { #a,-1, -1, &externPrivacy,b,PRIVACYVAL}
#define EMP(a,b) {#a,-1, -1, NULL,NULL,b}
#define EMP(a,b) {#a,-1, -1, 0, 0,b}
token_data_t tokens[] = {
PVAL(single, single_4),
@@ -305,7 +305,7 @@ yyylex()
unput_char();
*ptr = NULL;
*ptr = '\0';
externNumberVal=atoi((char *)parse_buffer);
return(NUMBER);
@@ -320,7 +320,7 @@ yyylex()
unput_char();
*ptr = NULL;
*ptr = '\0';
if ((bucket = tokens[hash_string((char *) parse_buffer)].first_token)
== -1) {

View File

@@ -319,9 +319,9 @@ _DtCmsAppendAppt4ByFD(int f, Appt_4 *appt, _DtCmsLogOps op)
and 1 BUFSIZ for the rest */
cptr = ctime (&appt->appt_id.tick);
cptr[24] = NULL; /* strip off CR */
cptr[24] = '\0'; /* strip off CR */
buf[0] = NULL;
buf[0] = '\0';
switch (op) {
case _DtCmsLogAdd:
sprintf(buf, "(add \"%s\" key: %ld ", cptr, appt->appt_id.key);
@@ -354,7 +354,7 @@ _DtCmsAppendAppt4ByFD(int f, Appt_4 *appt, _DtCmsLogOps op)
}
if (appt->period.enddate != 0) {
cptr = ctime (&(appt->period.enddate));
cptr[24] = NULL; /* strip off CR */
cptr[24] = '\0'; /* strip off CR */
sprintf(buf2, "enddate: \"%s\" ", cptr);
strcat(buf, buf2);
}
@@ -494,7 +494,7 @@ _DtCmsPrintAppt4(caddr_t data)
fprintf(stderr, "*** V4 appointement: ***\n\n");
tmstr = ctime (&appt->appt_id.tick);
tmstr[24] = NULL; /* strip off CR */
tmstr[24] = '\0'; /* strip off CR */
if (fprintf(stderr, "(add \"%s\" ", tmstr)==EOF) {
return (B_TRUE);
@@ -520,7 +520,7 @@ _DtCmsPrintAppt4(caddr_t data)
return (B_TRUE);
}
buf[0]=NULL;
buf[0] = '\0';
periodtostr (appt->period.period, buf);
if (fprintf(stderr, "period: %s ", buf) == EOF)
return (B_TRUE);
@@ -531,7 +531,7 @@ _DtCmsPrintAppt4(caddr_t data)
}
if (appt->period.enddate != 0) {
tmstr = ctime (&(appt->period.enddate));
tmstr[24] = NULL; /* strip off CR */
tmstr[24] = '\0'; /* strip off CR */
if (fprintf(stderr, "enddate: \"%s\" ", tmstr) == EOF)
return (B_TRUE);
}
@@ -573,7 +573,7 @@ _DtCmsPrintAppt4(caddr_t data)
if (fprintf(stderr, "tags: (") == EOF)
return (B_TRUE);
while(item != NULL) {
buf[0]=NULL;
buf[0] = '\0';
tagstostr(item->tag, buf);
if (fprintf(stderr, "(%s , %d)", buf, item->showtime)
== EOF)
@@ -585,12 +585,12 @@ _DtCmsPrintAppt4(caddr_t data)
}
buf[0]=NULL;
buf[0] = '\0';
apptstatustostr(appt->appt_status, buf);
if (fprintf(stderr, "apptstat: %s ", buf) == EOF)
return (B_TRUE);
buf[0]=NULL;
buf[0] = '\0';
privacytostr(appt->privacy, buf);
if (fprintf(stderr, "privacy: %s )\n", buf) == EOF)
return (B_TRUE);
@@ -647,8 +647,11 @@ _DtCmsTruncateFile(char *calendar, int size)
return;
/* truncate log file to specified size */
if ((f = open(log, O_RDWR | O_APPEND | O_SYNC)) >= 0)
ftruncate(f, size);
if ((f = open(log, O_RDWR | O_APPEND | O_SYNC)) >= 0) {
if(-1 == ftruncate(f, size)) {
perror(strerror(errno));
}
}
free(log);
}
@@ -691,12 +694,12 @@ _DtCmsWriteVersionString(char *file, int version)
tmval = time((time_t *) 0);
tm = _XLocaltime(&tmval, localtime_buf);
tmstr = _XAsctime(tm, asctime_buf);
tmstr[24] = NULL; /* strip off CR */
tmstr[24] = '\0'; /* strip off CR */
if ((fd = open(file, O_WRONLY|O_TRUNC|O_SYNC)) < 0) {
if (debug)
fprintf(stderr, "%s: failed to open %s in %s\n",
pgname, file, _DtCmsWriteVersionString);
fprintf(stderr, "%s: failed to open %s\n",
pgname, file);
return (CSA_X_DT_E_BACKING_STORE_PROBLEM);
}
@@ -733,7 +736,9 @@ _DtCmsSetFileMode(
#ifdef HPUX
setuid (0);
#else
seteuid (0);
if(-1 == seteuid (0)) {
perror(strerror(errno));
}
#endif
#endif
}
@@ -784,7 +789,7 @@ static void
periodtostr(Interval_4 i, char *q)
{
if (q==NULL) return;
q[0]=NULL;
q[0] = '\0';
switch (i) {
case single_4:
strcpy (q, "single");
@@ -838,7 +843,7 @@ static void
privacytostr(Privacy_Level_4 p, char *q)
{
if (q==NULL) return;
q[0]=NULL;
q[0] = '\0';
switch(p) {
case public_4:
strcpy(q, "public");
@@ -859,7 +864,7 @@ static void
apptstatustostr(Appt_Status_4 p, char *q)
{
if (q==NULL) return;
q[0]=NULL;
q[0] = '\0';
switch(p) {
case active_4:
strcpy(q, "active");
@@ -889,7 +894,7 @@ static void
tagstostr(Event_Type_4 p, char *q)
{
if (q==NULL) return;
q[0]=NULL;
q[0] = '\0';
switch(p) {
case appointment_4:
strcpy(q, "appointment");
@@ -933,7 +938,7 @@ create_log(char *owner, char *file, int version)
CSA_return_code stat;
ptr = strchr(owner, '@');
if (ptr) *ptr = NULL;
if (ptr) *ptr = '\0';
pw = getpwnam (owner);
if (ptr) *ptr = '@';
if (pw == NULL)
@@ -993,7 +998,10 @@ append_log(int f, char *buf)
status = CSA_X_DT_E_BACKING_STORE_PROBLEM;
perror(pgname);
ftruncate(f, file_size);
if(-1 == ftruncate(f, file_size)) {
perror(strerror(errno));
status = CSA_X_DT_E_BACKING_STORE_PROBLEM;
}
return (status);
}
@@ -1068,7 +1076,7 @@ attrs_to_attrliststr(
if ((buf = malloc(BUFSIZ+1)) == NULL) return (NULL);
tcount = BUFSIZ;
for (i = 1, count = 0, *buf = NULL; i <= num_attr; i++) {
for (i = 1, count = 0, *buf = '\0'; i <= num_attr; i++) {
if (attrs[i].value == NULL || (entryattrs &&
(i == CSA_ENTRY_ATTR_NUMBER_RECURRENCES_I ||
@@ -1089,7 +1097,7 @@ attrs_to_attrliststr(
/* value string */
body = NULL;
*tmpbuf2 = NULL;
*tmpbuf2 = '\0';
switch (attrs[i].value->type) {
case CSA_VALUE_ENUMERATED:
case CSA_VALUE_SINT32:
@@ -1207,7 +1215,7 @@ attrs_to_attrliststr(
tcount += BUFSIZ;
}
strcat(buf, tmpbuf);
if (*tmpbuf2 != NULL) strcat(buf, tmpbuf2);
if (*tmpbuf2 != '\0') strcat(buf, tmpbuf2);
if (body) strcat(buf, body);
strcat(buf, "\")\n");
if (body) free(body);
@@ -1280,7 +1288,7 @@ cr_to_str(char *s, int size)
k++;
}
}
newstr[k] = NULL;
newstr[k] = '\0';
return(newstr);
}

View File

@@ -272,7 +272,7 @@ appointmentBody : tick key what details duration period nth enddate ntimes excep
newp->author = $12;
newp->attr = $13;
if (temp != NULL && (*temp)!=NULL) {
if (temp != NULL && (*temp)!='\0') {
item = newp->attr;
while(item!=NULL) {
if(strcmp(item->attr, "ml")==0) {
@@ -372,7 +372,7 @@ mailto : /* empty */
duration : /* empty */
{
$$ = NULL;
$$ = '\0';
}
| DURATION COLON number
{
@@ -693,7 +693,7 @@ str_to_cr(char *s)
}
k++;
}
newstr[k] = NULL;
newstr[k] = '\0';
return(newstr);
}
@@ -763,7 +763,7 @@ convert_2_tick(char *datestr)
if (datestr == NULL)
return (-1);
memset((void *)&tmstr, NULL, sizeof(struct tm));
memset((void *)&tmstr, 0, sizeof(struct tm));
strcpy(datebuf, datestr);
@@ -791,7 +791,7 @@ convert_2_tick(char *datestr)
if ((tptr = strchr(ptr, ':')) == NULL)
return (-1);
else {
*tptr = NULL;
*tptr = '\0';
tmstr.tm_hour = atoi(ptr);
}
@@ -799,7 +799,7 @@ convert_2_tick(char *datestr)
if ((tptr = strchr(ptr, ':')) == NULL)
return (-1);
else {
*tptr = NULL;
*tptr = '\0';
tmstr.tm_min = atoi(ptr);
}
@@ -907,11 +907,11 @@ get_attr_value(int type, char *valstr, cms_attribute_value **attrval)
stat = _DtCm_set_string_attrval(valstr, attrval, type);
break;
case CSA_VALUE_REMINDER:
memset((void *)&remval, NULL, sizeof (CSA_reminder));
memset((void *)&remval, 0, sizeof (CSA_reminder));
if (ptr1 = strchr(valstr, ':')) {
*ptr1++ = NULL;
*ptr1++ = '\0';
if (ptr2 = strchr(ptr1, ':')) {
*ptr2++ = NULL;
*ptr2++ = '\0';
ptr3 = strchr(ptr2, ':');
}
}
@@ -929,9 +929,9 @@ get_attr_value(int type, char *valstr, cms_attribute_value **attrval)
stat = _DtCm_set_reminder_attrval(&remval, attrval);
} else {
/* format = "string:string:number:number:string" */
*ptr3++ = NULL;
*ptr3++ = '\0';
if (ptr4 = strchr(ptr3, ':')) {
*ptr4++ = NULL;
*ptr4++ = '\0';
remval.lead_time = valstr;
remval.snooze_time = ptr1;
remval.repeat_count = atoi(ptr2);
@@ -953,7 +953,7 @@ get_attr_value(int type, char *valstr, cms_attribute_value **attrval)
break;
case CSA_VALUE_OPAQUE_DATA:
if (ptr1 = strchr(valstr, ':')) {
*ptr1++ = NULL;
*ptr1++ = '\0';
opqval.size = atoi(valstr);
opqval.data = (unsigned char *)ptr1;
stat = _DtCm_set_opaque_attrval(&opqval, attrval);
@@ -1042,7 +1042,7 @@ get_user_access_entry(char *string, cms_access_entry **a)
return (CSA_E_INSUFFICIENT_MEMORY);
}
*ptr = NULL;
*ptr = '\0';
if ((item->user = strdup(string)) == NULL) {
free(item);
return (CSA_E_INSUFFICIENT_MEMORY);
@@ -1070,7 +1070,7 @@ grow_attr_array(_attr_array *attrs)
attrs->total += _DEFAULT_ARRAY_SIZE;
attrs->attrs = newptr;
memset((void *)&attrs->attrs[attrs->current], NULL,
memset((void *)&attrs->attrs[attrs->current], 0,
sizeof(cms_attribute)*_DEFAULT_ARRAY_SIZE);
}

View File

@@ -352,7 +352,7 @@ DoWeek(
if (_target_time) {
if (!(unused = InitRepeatEventState(re)))
return (Tick)NULL;
start_time = DoWeek(NULL, _start_time, re, unused);
start_time = DoWeek(0, _start_time, re, unused);
free(unused);
if (_target_time < start_time)
target_time = start_time;
@@ -677,7 +677,7 @@ DoYearByMonth(
if (_target_time) {
if (!(unused = InitRepeatEventState(re)))
return (Tick)NULL;
start_time = DoYearByMonth(NULL, _start_time, re, unused);
start_time = DoYearByMonth(0, _start_time, re, unused);
free(unused);
if (_target_time < start_time)
target_time = start_time;
@@ -781,7 +781,7 @@ DoYearByDay(
if (_target_time) {
if (!(unused = InitRepeatEventState(re)))
return (Tick)NULL;
start_time = DoYearByDay(NULL, _start_time, re, unused);
start_time = DoYearByDay(0, _start_time, re, unused);
free(unused);
if (_target_time < start_time)
target_time = start_time;

View File

@@ -76,7 +76,7 @@ static int monthsecs[12] = {
31*daysec, 30*daysec, 31*daysec
};
extern int monthdays[12] = {
int monthdays[12] = {
31, 28, 31,
30, 31, 30,
31, 31, 30,

View File

@@ -106,7 +106,7 @@ ReToString(
strcat (cmd_buf, subcommand);
}
memset (subcommand, NULL, 1024);
memset (subcommand, 0, 1024);
re = re->re_next;
}

View File

@@ -305,7 +305,7 @@ DeriveNewStartTime(
* time should be.
*/
while (--num_events &&
(an_event = PrevTick(an_event, NULL, new_re, res))) {
(an_event = PrevTick(an_event, 0, new_re, res))) {
;
}

View File

@@ -112,7 +112,7 @@ _GetGtime(char *timestr)
}
minute = atoi(&timestr[len - 2]);
timestr[len - 2] = NULL;
timestr[len - 2] = '\0';
hour = atoi(timestr);
if (hour > 23 || minute > 59)
@@ -273,7 +273,9 @@ init_dir()
}
/* Change current directory, so core file can be dumped. */
chdir (dir);
if(-1 == chdir (dir)) {
perror(strerror(errno));
}
}
/*
@@ -754,8 +756,12 @@ main(int argc, char **argv)
setgid (daemon_gid);
setuid (daemon_uid);
#else
setegid (daemon_gid);
seteuid (daemon_uid);
if(-1 == setegid (daemon_gid)) {
perror(strerror(errno));
}
if(-1 == seteuid (daemon_uid)) {
perror(strerror(errno));
}
#endif /* HPUX */
#endif /* AIX */

View File

@@ -319,14 +319,14 @@ _DtCmsUpdateDurationInRule(cms_entry *entry, uint remain)
sprintf(buf, "#%d", remain);
if (ptr = strchr(vptr->item.string_value, '#')) {
*ptr = NULL;
*ptr = '\0';
strcpy(newrule, vptr->item.string_value);
strcat(newrule, buf);
if (ptr = strchr(ptr + 1, ' '))
strcat(newrule, ptr);
} else {
if (ptr = strchr(vptr->item.string_value, ' ')) {
*ptr = NULL;
*ptr = '\0';
sprintf(newrule, "%s %s %s", vptr->item.string_value,
buf, ptr+1);
} else