diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-04-30 23:04:53 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-04-30 23:05:37 -0400 |
commit | 321c7710c3f3a17d56e9e5eede9aebadbaf16e3e (patch) | |
tree | fae8712111ede1cd948e8846a3bbdafeb8dfd45a /gpspipe.c | |
parent | 5aa7ce8d00de15c832ab90113ef5b08221746e7f (diff) | |
download | gpsd-321c7710c3f3a17d56e9e5eede9aebadbaf16e3e.tar.gz |
Fix static-checker warnings. All regression tests pass.
cppchecker now finds variables that could have reduced scope;
that's most of these.
Diffstat (limited to 'gpspipe.c')
-rw-r--r-- | gpspipe.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -323,21 +323,24 @@ int main(int argc, char **argv) if (new_line && timestamp) { char tmstr_u[20]; // time with "usec" resolution struct timeval now; - gettimeofday( &now, NULL ); + struct tm *tmp_now; - struct tm *tmp_now = localtime(&(now.tv_sec)); + (void)gettimeofday( &now, NULL ); + tmp_now = localtime((time_t *)&(now.tv_sec)); (void)strftime(tmstr, sizeof(tmstr), format, tmp_now); new_line = 0; switch( option_u ) { - case 2: - sprintf(tmstr_u, " %ld.%06ld", now.tv_sec, now.tv_usec); + case 2: + (void)snprintf(tmstr_u, sizeof(tmstr_u), + " %ld.%06ld", now.tv_sec, now.tv_usec); break; - case 1: - sprintf(tmstr_u, ".%06ld", now.tv_usec); + case 1: + (void)snprintf(tmstr_u, sizeof(tmstr_u), + ".%06ld", now.tv_usec); break; - default: - *tmstr_u=0; + default: + *tmstr_u = '\0'; break; } |