commit c6d7f2956d5d8508641915e5f6202401f809eb3b
parent 95dd38f361630f81f7970286547216b6e35abafd
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Wed, 2 Apr 2014 16:04:47 +0200
sfeed_stats: cleanup, use strlcpy
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
Diffstat:
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/sfeed_stats.c b/sfeed_stats.c
@@ -47,7 +47,6 @@ main(void) {
if(!totalfeeds || (feedcurrent && strcmp(feedcurrent->name, fields[FieldFeedName]))) { /* TODO: allocate feedcurrent before here, feedcurrent can be NULL */
if(!(f = calloc(1, sizeof(struct feed))))
die("can't allocate enough memory");
- /*f->next = NULL;*/
if(totalfeeds) { /* end previous one. */
feedcurrent->next = f;
feedcurrent = f;
@@ -57,24 +56,19 @@ main(void) {
}
if(parsedtime > timenewest) {
timenewest = parsedtime;
- strncpy(timenewestformat, fields[FieldTimeFormatted],
- sizeof(timenewestformat)); /* TODO: strlcpy */
+ strlcpy(timenewestformat, fields[FieldTimeFormatted],
+ sizeof(timenewestformat));
}
if(parsedtime > feedcurrent->timenewest) {
feedcurrent->timenewest = parsedtime;
- strncpy(feedcurrent->timenewestformat, fields[FieldTimeFormatted],
- sizeof(feedcurrent->timenewestformat)); /* TODO: strlcpy */
+ strlcpy(feedcurrent->timenewestformat, fields[FieldTimeFormatted],
+ sizeof(feedcurrent->timenewestformat));
}
/* TODO: memcpy and make feedcurrent->name static? */
if(!(feedcurrent->name = strdup(fields[FieldFeedName])))
die("can't allocate enough memory");
- /*
- feedcurrent->totalnew = 0;
- feedcurrent->total = 0;
- feedcurrent->next = NULL;*/
-
totalfeeds++;
}
totalnew += isnew;
@@ -85,7 +79,6 @@ main(void) {
for(feedcurrent = feeds; feedcurrent; feedcurrent = feedcurrent->next) {
if(!feedcurrent->name || feedcurrent->name[0] == '\0')
continue;
-/* printfeednameid(feedcurrent->name, stdout);*/
fprintf(stdout, "%c %-20.20s [%4lu/%-4lu]", feedcurrent->totalnew > 0 ? 'N' : ' ',
feedcurrent->name, feedcurrent->totalnew, feedcurrent->total);
if(feedcurrent->timenewestformat && feedcurrent->timenewestformat[0])