summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2014-04-02 16:04:47 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2014-04-02 16:04:47 +0200
commitc6d7f2956d5d8508641915e5f6202401f809eb3b (patch)
tree902d01f672b412200d46cd8c5c863f78dc3a872e
parent95dd38f361630f81f7970286547216b6e35abafd (diff)
sfeed_stats: cleanup, use strlcpy
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
-rw-r--r--sfeed_stats.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/sfeed_stats.c b/sfeed_stats.c
index 0190e2f..9846e38 100644
--- 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])