parentheses added to fix a warning

sprintf replaced by snprintf and strcpy replaced by strncpy
This commit is contained in:
Frederic Culot 2006-12-15 15:29:16 +00:00
parent cbdee3d133
commit 6da1452a0f

View File

@ -1,4 +1,4 @@
/* $calcurse: day.c,v 1.13 2006/12/14 08:26:24 culot Exp $ */ /* $calcurse: day.c,v 1.14 2006/12/15 15:29:16 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -153,8 +153,8 @@ int day_store_recur_apoints(long date)
pthread_mutex_lock(&(recur_alist_p->mutex)); pthread_mutex_lock(&(recur_alist_p->mutex));
for (j = recur_alist_p->root; j != 0; j = j->next) { for (j = recur_alist_p->root; j != 0; j = j->next) {
if (real_start = recur_item_inday(j->start, j->exc, if ((real_start = recur_item_inday(j->start, j->exc,
j->rpt->type, j->rpt->freq, j->rpt->until, date)) { j->rpt->type, j->rpt->freq, j->rpt->until, date)) ){
a_nb++; a_nb++;
ptr = day_add_apoint( ptr = day_add_apoint(
RECUR_APPT, j->mesg, real_start, j->dur, n); RECUR_APPT, j->mesg, real_start, j->dur, n);
@ -197,7 +197,7 @@ struct day_item_s *day_add_event(int type, char *mesg, long day, int id)
struct day_item_s *o, **i; struct day_item_s *o, **i;
o = (struct day_item_s *) malloc(sizeof(struct day_item_s)); o = (struct day_item_s *) malloc(sizeof(struct day_item_s));
o->mesg = (char *) malloc(strlen(mesg) + 1); o->mesg = (char *) malloc(strlen(mesg) + 1);
strcpy(o->mesg, mesg); strncpy(o->mesg, mesg, strlen(mesg) + 1);
o->type = type; o->type = type;
o->appt_dur = 0; o->appt_dur = 0;
o->appt_pos = 0; o->appt_pos = 0;
@ -224,7 +224,7 @@ struct day_item_s *day_add_apoint(int type, char *mesg, long start, long dur,
o = (struct day_item_s *) malloc(sizeof(struct day_item_s)); o = (struct day_item_s *) malloc(sizeof(struct day_item_s));
o->mesg = (char *) malloc(strlen(mesg) + 1); o->mesg = (char *) malloc(strlen(mesg) + 1);
strcpy(o->mesg, mesg); strncpy(o->mesg, mesg, strlen(mesg) + 1);
o->start = start; o->start = start;
o->appt_dur = dur; o->appt_dur = dur;
o->appt_pos = real_pos; o->appt_pos = real_pos;
@ -522,7 +522,7 @@ void day_edit_item(int year, int month, int day, int item_num, int colr)
while (newfreq == 0) { while (newfreq == 0) {
status_mesg(mesg_freq_1, ""); status_mesg(mesg_freq_1, "");
freqstr = (char *) malloc(MAX_LENGTH); freqstr = (char *) malloc(MAX_LENGTH);
sprintf(freqstr, "%d", rpt->freq); snprintf(freqstr, MAX_LENGTH, "%d", rpt->freq);
cancel = updatestring(swin, colr, &freqstr, 0, 1); cancel = updatestring(swin, colr, &freqstr, 0, 1);
newfreq = atoi(freqstr); newfreq = atoi(freqstr);
free(freqstr); free(freqstr);