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

@@ -196,13 +196,13 @@ mini_err_msg(
char *buf, *ptr;
if (type == TTY_Insert)
fprintf(stderr, "%s %s",
fprintf(stderr, "%s",
catgets(catd, 1, 1042, "Insert Access Denied: "));
else if (type == TTY_Delete)
fprintf(stderr, "%s %s",
fprintf(stderr, "%s",
catgets(catd, 1, 1043, "Delete Access Denied: "));
else
fprintf(stderr, "%s %s",
fprintf(stderr, "%s",
catgets(catd, 1, 1044, "Lookup Access Denied: "));
if (appt_what && appt_what[0] != '\0') {
@@ -398,7 +398,7 @@ scrub_attr_list(Dtcm_appointment *appt) {
for (i = 0; i < appt->count; i++) {
if (appt->attrs[i].value->type == CSA_VALUE_REMINDER) {
if ((appt->attrs[i].value->item.reminder_value->lead_time == NULL) ||
(appt->attrs[i].value->item.reminder_value->lead_time[0] == NULL)) {
(appt->attrs[i].value->item.reminder_value->lead_time[0] == '\0')) {
free(appt->attrs[i].name);
appt->attrs[i].name = NULL;
}
@@ -613,7 +613,7 @@ cm_tty_lookup(nl_catd catd, CSA_session_handle target, int version, char *date,
start = lowerbound(tick - (day * daysec));
stop = next_ndays(start, span) - 1;
setup_range(&range_attrs, &ops, &i, start, stop, CSA_TYPE_EVENT,
NULL, B_FALSE, version);
0, B_FALSE, version);
status = csa_list_entries(target, i, range_attrs, ops, &a_total, list, NULL);
free_range(&range_attrs, &ops, i);
@@ -653,7 +653,7 @@ cm_tty_lookup(nl_catd catd, CSA_session_handle target, int version, char *date,
if (appt->end_time)
format_time(end_tick, dt, end_buf);
else
*end_buf = NULL;
*end_buf = '\0';
sprintf(buf, "%s%c%7s ", start_buf,
(*end_buf ? '-' : ' '), end_buf);
}
@@ -964,7 +964,7 @@ build_new_attrval(CSA_attribute *attrval, char *name, char *tag, char *value)
if (!strcmp(tag, "caluser")) {
vptr->type = CSA_VALUE_CALENDAR_USER;
s_ptr = strchr(value, ':');
*s_ptr = NULL;
*s_ptr = '\0';
vptr->item.calendar_user_value = calloc(sizeof(CSA_calendar_user), 1);
vptr->item.calendar_user_value->user_name = cm_strdup(s_ptr + 1);
vptr->item.calendar_user_value->user_type = atoi(value);
@@ -983,7 +983,7 @@ build_new_attrval(CSA_attribute *attrval, char *name, char *tag, char *value)
if (!strcmp(tag, "reminder")) {
vptr->type = CSA_VALUE_REMINDER;
s_ptr = strchr(value, ':');
*s_ptr = NULL;
*s_ptr = '\0';
vptr->item.reminder_value = calloc(sizeof(CSA_reminder), 1);
@@ -1012,13 +1012,13 @@ build_new_attrval(CSA_attribute *attrval, char *name, char *tag, char *value)
l_ptr = calloc(sizeof(CSA_access_rights), 1);
s_ptr = strchr(b_ptr, ':');
*s_ptr = NULL;
*s_ptr = '\0';
l_ptr->rights = atoi(b_ptr);
b_ptr = s_ptr + 1;
if (s_ptr = strchr(b_ptr, '\n'))
*s_ptr = NULL;
*s_ptr = '\0';
l_ptr->user->user_name = cm_strdup(b_ptr);
@@ -1112,7 +1112,7 @@ read_new_appt(FILE *fp, Dtcm_appointment **appt, Props *p, int version)
strcat(a_value, "\n");
strcat(a_value, b_ptr);
a_value[strlen(a_value) - 1] = NULL;
a_value[strlen(a_value) - 1] = '\0';
continue;
}
@@ -1161,7 +1161,7 @@ read_new_appt(FILE *fp, Dtcm_appointment **appt, Props *p, int version)
b_ptr = line;
if (c_ptr = strchr(line, ':'))
{
*c_ptr = NULL;
*c_ptr = '\0';
a_name = cm_strdup(b_ptr);
}
else
@@ -1175,7 +1175,7 @@ read_new_appt(FILE *fp, Dtcm_appointment **appt, Props *p, int version)
if (c_ptr = strchr(b_ptr, ':'))
{
*c_ptr = NULL;
*c_ptr = '\0';
a_tag = cm_strdup(b_ptr);
}
else
@@ -1187,7 +1187,7 @@ read_new_appt(FILE *fp, Dtcm_appointment **appt, Props *p, int version)
if (!*b_ptr)
break;
else
b_ptr[strlen(b_ptr) - 1] = NULL;
b_ptr[strlen(b_ptr) - 1] = '\0';
a_value = cm_strdup(b_ptr);
}
@@ -1667,7 +1667,7 @@ cat_indented_string(char **catbuf, char *string)
*b_ptr++ = '\t';
p_str++;
}
*b_ptr = NULL;
*b_ptr = '\0';
growcat(catbuf, buf);
@@ -1683,12 +1683,12 @@ attrs_to_string(CSA_attribute * attrs, int num_attrs)
char tmp_buf[MAXNAMELEN];
int advance_time;
buffer[0] = NULL;
buffer[0] = '\0';
for (i = 0; i < num_attrs; i++) {
if (!attrs[i].name || (attrs[i].value == NULL))
continue;
tmp_buf[0] = NULL;
tmp_buf[0] = '\0';
sprintf(tmp_buf, "%s:", attrs[i].name);
switch (attrs[i].value->type) {
case CSA_VALUE_SINT32:
@@ -1765,7 +1765,7 @@ attrs_to_string(CSA_attribute * attrs, int num_attrs)
a_ptr = attrs[i].value->item.access_list_value;
while (a_ptr) {
sprintf(tmp_buf, "\t%d:%s\n",
a_ptr->rights, a_ptr->user->user_name);
(int) a_ptr->rights, a_ptr->user->user_name);
growcat(&buffer, tmp_buf);
a_ptr = a_ptr->next;
}
@@ -1865,11 +1865,11 @@ parse_attrs_to_string(Dtcm_appointment *appt, Props *p, char *attr_string) {
CSA_uint32 repeat_times;
static char *format_string = "\n\n\t** Calendar Appointment **\n%s:string:begin\n%s%s:string:end\n\tDate: %s\n\tStart: %s\n\tEnd: %s\n\tRepeat: %s\n\tFor: %s\n\tWhat: %s";
s_buf[0] = NULL;
e_buf[0] = NULL;
w_buf[0] = NULL;
r_buf[0] = NULL;
f_buf[0] = NULL;
s_buf[0] = '\0';
e_buf[0] = '\0';
w_buf[0] = '\0';
r_buf[0] = '\0';
f_buf[0] = '\0';
_csa_iso8601_to_tick(appt->time->value->item.date_time_value, &tick);
if (appt->end_time)
@@ -2144,7 +2144,7 @@ str_to_period(char *ps, CSA_sint32 *repeat_type, int *repeat_nth) {
boolean_t compute_times = B_FALSE;
char *ps2, *ptr, *ptr2, *unit;
*repeat_type = NULL;
*repeat_type = '\0';
*repeat_nth = 0;
if (ps == NULL)
return;
@@ -2186,7 +2186,7 @@ str_to_period(char *ps, CSA_sint32 *repeat_type, int *repeat_nth) {
ps2 = cm_strdup(unit);
ptr = strchr(ps2, ' ');
if (ptr != NULL)
*ptr = NULL;
*ptr = '\0';
else
return;
@@ -2235,13 +2235,13 @@ periodstr_from_period(CSA_sint32 repeat_type, int repeat_nth) {
sprintf(pstr, "%s", periodstrings[6]);
break;
case CSA_X_DT_REPEAT_EVERY_NDAY:
sprintf(pstr, "Every %ld %s", repeat_nth, periodstrings[7]);
sprintf(pstr, "Every %d %s", repeat_nth, periodstrings[7]);
break;
case CSA_X_DT_REPEAT_EVERY_NWEEK:
sprintf(pstr, "Every %ld %s", repeat_nth, periodstrings[8]);
sprintf(pstr, "Every %d %s", repeat_nth, periodstrings[8]);
break;
case CSA_X_DT_REPEAT_EVERY_NMONTH:
sprintf(pstr, "Every %ld %s", repeat_nth, periodstrings[9]);
sprintf(pstr, "Every %d %s", repeat_nth, periodstrings[9]);
break;
case CSA_X_DT_REPEAT_OTHER:
sprintf(pstr, "%s", periodstrings[10]);

View File

@@ -923,7 +923,7 @@ xytoclock(int x, int y, Tick t)
Tick tick;
_Xltimeparams localtime_buf;
memset(&timestruct, NULL, sizeof(struct tm));
memset(&timestruct, 0, sizeof(struct tm));
tm = *_XLocaltime(&t, localtime_buf);
mn = tm.tm_mon + 1;
@@ -1094,7 +1094,7 @@ monthdayyear(int m, int d, int y)
struct tm timestruct;
memset(&timestruct, NULL, sizeof(struct tm));
memset(&timestruct, 0, sizeof(struct tm));
timestruct.tm_mon = m - 1;
timestruct.tm_mday = d;
timestruct.tm_year = y - 1900;

View File

@@ -146,7 +146,7 @@ cm_def_printer()
}
#else
tmp = (char*)getenv("PRINTER");
if (tmp != NULL && *tmp != NULL) {
if (tmp != NULL && *tmp != '\0') {
printer_name = (char*)malloc(strlen(tmp)+1);
strcpy(printer_name, tmp);
}
@@ -187,7 +187,7 @@ cm_strlen(register char *s)
{
register int n;
if (s==NULL) return NULL;
if (s==NULL) return 0;
return (strlen(s));
}
@@ -246,7 +246,7 @@ str_to_cr(char *s)
}
k++;
}
newstr[k] = NULL;
newstr[k] = '\0';
return(newstr);
}
@@ -286,7 +286,7 @@ cr_to_str(char *s)
k++;
}
}
newstr[k] = NULL;
newstr[k] = '\0';
return(newstr);
}
@@ -504,7 +504,7 @@ get_head(char *str, char sep)
if (ptr == buf)
return(NULL);
else {
*ptr = NULL;
*ptr = '\0';
return(cm_strdup(buf));
}
}
@@ -584,7 +584,10 @@ cm_get_local_domain()
#if defined(sun) || defined(USL) || defined(__uxp__)
sysinfo(SI_SRPC_DOMAIN, local_domain, DOM_NM_LN);
#else
(void) getdomainname(local_domain, BUFSIZ);
if(-1 == getdomainname(local_domain, BUFSIZ)) {
fprintf(stderr, "getdomainname() failed %d '%s'\n", errno, strerror(errno));
}
#endif /* sun || USL || __uxp__ */
}
return(local_domain);
@@ -733,10 +736,10 @@ match_forward(char *str1, char *str2)
get_component(&str2, com2, '.');
if (*com1) {
if (*com2 == NULL)
if (*com2 == '\0')
return (B_TRUE);
} else {
if (*com2 == NULL)
if (*com2 == '\0')
return (B_TRUE);
else
return (B_FALSE);
@@ -747,18 +750,18 @@ match_forward(char *str1, char *str2)
/* take care of case: a.b a. */
if (strcmp(str2, ".") == 0
&& (strcmp(str1, ".") != 0 || *str1 != NULL))
&& (strcmp(str1, ".") != 0 || *str1 != '\0'))
return (B_FALSE);
/* skip "." */
if (*str1 == '.') {
if (*str2 == NULL)
if (*str2 == '\0')
return (B_TRUE);
else {
str1++;
str2++;
}
} else if (strcmp(str2, ".") == 0 || *str2 == NULL)
} else if (strcmp(str2, ".") == 0 || *str2 == '\0')
return (B_TRUE);
else
return (B_FALSE);
@@ -796,10 +799,10 @@ match_backward(char *str1, char *str2)
get_last_component(str2, &ptr2, com2, '.');
if (*com1) {
if (*com2 == NULL)
if (*com2 == '\0')
return (B_TRUE);
} else {
if (*com2 == NULL)
if (*com2 == '\0')
return (B_TRUE);
else
return (B_FALSE);
@@ -1041,9 +1044,9 @@ parse_date(OrderingType order, SeparatorType sep, char *datestr, char *m,
char *tmp_date, *str = separator_str(sep);
_Xstrtokparams strtok_buf;
m[0] = NULL;
d[0] = NULL;
y[0] = NULL;
m[0] = '\0';
d[0] = '\0';
y[0] = '\0';
if (datestr == NULL)
return 0;
@@ -1098,7 +1101,7 @@ extern int
datestr2mdy(char *datestr, OrderingType order, SeparatorType sep, char *buf) {
char m[3], d[3], y[5];
buf[0] = NULL;
buf[0] = '\0';
if (datestr == NULL)
return 0;
@@ -1124,7 +1127,7 @@ format_tick(Tick tick, OrderingType order, SeparatorType sep, char *buff) {
struct tm *tm;
_Xltimeparams localtime_buf;
buff[0] = NULL;
buff[0] = '\0';
tm = _XLocaltime(&tick, localtime_buf);
switch (order) {
@@ -1150,7 +1153,7 @@ format_time(Tick t, DisplayType dt, char *buffer) {
boolean_t am;
if (t == 0) {
sprintf(buffer, "\0");
buffer[0] = '\0';
} else if (dt == HOUR12) {
am = adjust_hour(&hr);
@@ -1234,7 +1237,7 @@ Dtcm_appointment *allocate_appt_struct (Allocation_reason reason, int version, .
*/
idx = sizeof(Dtcm_appointment);
appt = (Dtcm_appointment *)ckalloc(idx);
memset(appt, NULL, idx);
memset(appt, 0, idx);
appt->reason = reason;
appt->version = version;
@@ -1246,7 +1249,7 @@ Dtcm_appointment *allocate_appt_struct (Allocation_reason reason, int version, .
api_idx = va_arg(pvar, int);
while (api_idx) {
if ((reason == appt_read) || !entry_ident_index_ro(api_idx, version))
CmDataListAdd(api_ids, (void *)api_idx, 0);
CmDataListAdd(api_ids, (void *) (intptr_t) api_idx, 0);
api_idx = va_arg(pvar, int);
}
va_end(pvar);
@@ -1268,7 +1271,7 @@ Dtcm_appointment *allocate_appt_struct (Allocation_reason reason, int version, .
for (idx = 0; idx < def_attr_count; idx++) {
if ((reason == appt_write) && entry_ident_index_ro(default_appt_attrs[idx], version))
continue;
CmDataListAdd(api_ids, (void *)default_appt_attrs[idx], 0);
CmDataListAdd(api_ids, (void *) (intptr_t) default_appt_attrs[idx], 0);
}
}
@@ -1281,20 +1284,20 @@ Dtcm_appointment *allocate_appt_struct (Allocation_reason reason, int version, .
appt->num_names = api_ids->count;
idx = sizeof(CSA_attribute_reference *) * appt->num_names;
appt->names = (CSA_attribute_reference *)ckalloc(idx);
memset(appt->names, NULL, idx);
memset(appt->names, 0, idx);
appt->count = api_ids->count;
if (reason == appt_write) {
idx = sizeof(CSA_attribute) * appt->count;
appt->attrs = (CSA_attribute *)ckalloc(idx);
memset(appt->attrs, NULL, idx);
memset(appt->attrs, 0, idx);
}
/*
* Now loop through and set the names and initialize the attributes
*/
for (idx = 0; idx < appt->count; idx++) {
api_idx = (int)CmDataListGetData(api_ids, idx + 1);
api_idx = (int) (intptr_t) CmDataListGetData(api_ids, idx + 1);
appt->names[idx] = strdup(_CSA_entry_attribute_names[api_idx]);
if (reason == appt_write)
initialize_entry_attr(api_idx, &appt->attrs[idx], reason, version);
@@ -1303,7 +1306,7 @@ Dtcm_appointment *allocate_appt_struct (Allocation_reason reason, int version, .
if (reason == appt_write)
set_appt_links(appt);
CmDataListDestroy(api_ids, NULL);
CmDataListDestroy(api_ids, 0);
return appt;
}
@@ -1356,7 +1359,7 @@ allocate_cal_struct(Allocation_reason reason, int version, ...) {
*/
idx = sizeof(Dtcm_calendar);
cal = (Dtcm_calendar *)ckalloc(idx);
memset(cal, NULL, idx);
memset(cal, 0, idx);
cal->reason = reason;
cal->version = version;
@@ -1368,7 +1371,7 @@ allocate_cal_struct(Allocation_reason reason, int version, ...) {
api_idx = va_arg(pvar, int);
while (api_idx) {
if ((reason == appt_read) || !cal_ident_index_ro(api_idx, version))
CmDataListAdd(api_ids, (void *)api_idx, 0);
CmDataListAdd(api_ids, (void *) (intptr_t) api_idx, 0);
api_idx = va_arg(pvar, int);
}
va_end(pvar);
@@ -1380,7 +1383,7 @@ allocate_cal_struct(Allocation_reason reason, int version, ...) {
for (idx = 0; idx < DEF_CAL_ATTR_COUNT; idx++) {
if ((reason == appt_write) && cal_ident_index_ro(default_cal_attrs[idx], version))
continue;
CmDataListAdd(api_ids, (void *)default_cal_attrs[idx], 0);
CmDataListAdd(api_ids, (void *) (intptr_t) default_cal_attrs[idx], 0);
}
}
@@ -1393,20 +1396,20 @@ allocate_cal_struct(Allocation_reason reason, int version, ...) {
cal->num_names = api_ids->count;
idx = sizeof(CSA_attribute_reference) * cal->num_names;
cal->names = (CSA_attribute_reference *)ckalloc(idx);
memset(cal->names, NULL, idx);
memset(cal->names, 0, idx);
cal->count = api_ids->count;
if (reason == appt_write) {
idx = sizeof(CSA_attribute) * cal->count;
cal->attrs = (CSA_attribute *)ckalloc(idx);
memset(cal->attrs, NULL, idx);
memset(cal->attrs, 0, idx);
}
/*
* Now loop through and set the names and initialize the attributes
*/
for (idx = 0; idx < cal->count; idx++) {
api_idx = (int)CmDataListGetData(api_ids, idx + 1);
api_idx = (int) (intptr_t) CmDataListGetData(api_ids, idx + 1);
cal->names[idx] = strdup(_CSA_calendar_attribute_names[api_idx]);
if (reason == appt_write)
initialize_cal_attr(api_idx, &cal->attrs[idx], reason, version);
@@ -1415,7 +1418,7 @@ allocate_cal_struct(Allocation_reason reason, int version, ...) {
if (reason == appt_write)
set_cal_links(cal);
CmDataListDestroy(api_ids, NULL);
CmDataListDestroy(api_ids, 0);
return cal;
@@ -1455,7 +1458,7 @@ scrub_cal_attr_list(Dtcm_calendar *cal) {
for (i = 0; i < cal->count; i++) {
if (cal->attrs[i].value->type == CSA_VALUE_REMINDER) {
if ((cal->attrs[i].value->item.reminder_value->lead_time == NULL) ||
(cal->attrs[i].value->item.reminder_value->lead_time[0] == NULL)) {
(cal->attrs[i].value->item.reminder_value->lead_time[0] == '\0')) {
free(cal->attrs[i].name);
cal->attrs[i].name = NULL;
}
@@ -1665,7 +1668,7 @@ initialize_cal_attr(int id, CSA_attribute *attrs, Allocation_reason reason, int
if ((reason == appt_write) && !cal_ident_index_ro(id, version)) {
size = sizeof(CSA_attribute_value);
attrs->value = (CSA_attribute_value *)ckalloc(size);
memset(attrs->value, NULL, size);
memset(attrs->value, 0, size);
attrs->value->type = cal_ident_index_tag(id);
if (attrs->value->type == CSA_VALUE_REMINDER)
attrs->value->item.reminder_value = (CSA_reminder *) calloc(sizeof(CSA_reminder), 1);
@@ -1709,7 +1712,7 @@ initialize_entry_attr(int id, CSA_attribute *attrs, Allocation_reason reason, in
if ((reason == appt_write) && !entry_ident_index_ro(id, version)) {
size = sizeof(CSA_attribute_value);
attrs->value = (CSA_attribute_value *)ckalloc(size);
memset(attrs->value, NULL, size);
memset(attrs->value, 0, size);
attrs->value->type = entry_ident_index_tag(id);
if (attrs->value->type == CSA_VALUE_REMINDER)
attrs->value->item.reminder_value = (CSA_reminder *) calloc(sizeof(CSA_reminder), 1);
@@ -1900,11 +1903,11 @@ setup_range(CSA_attribute **attrs, CSA_enum **ops, int *count, time_t start,
a_size = sizeof(CSA_attribute) * (*count);
attr_ptr = (CSA_attribute *)ckalloc(a_size);
memset(attr_ptr, NULL, a_size);
memset(attr_ptr, 0, a_size);
o_size = sizeof(CSA_enum) * (*count);
op_ptr = (CSA_enum *)ckalloc(o_size);
memset(op_ptr, NULL, o_size);
memset(op_ptr, 0, o_size);
initialize_entry_attr(CSA_ENTRY_ATTR_START_DATE_I, &attr_ptr[0], appt_write, version);
attr_ptr[0].value->item.string_value = malloc(BUFSIZ);