Skip to content

add support for TIME command#63

Merged
maralla merged 3 commits intoeleme:masterfrom
jasonjoo2010:master
May 26, 2016
Merged

add support for TIME command#63
maralla merged 3 commits intoeleme:masterfrom
jasonjoo2010:master

Conversation

@jasonjoo2010
Copy link
Copy Markdown
Contributor

fork using lastest code

src/command.c Outdated
char time_sec[15];
char time_us[10];
snprintf(time_sec, sizeof(time_sec), "%d", tm.tv_sec);
snprintf(time_us, sizeof(time_us), "%d", tm.tv_usec);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Linux tv_sec and tv_usec are all long, it would be better to use %ld instead of %d. And time_sec and time_us are not large enough to hold 8 bytes integer.

char time_sec[21], time_us[21];
int sec_len = snprintf(time_sec, 20, "%ld", tm.tv_sec);
int usec_len = snprintf(time_us, 20, "%ld", tm.tv_usec);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, fix the 2038 year problem altogether
fix the intent of code using space chars
add the error logging

& made a new commit on this

Thank you for your responding

@maralla
Copy link
Copy Markdown
Contributor

maralla commented May 25, 2016

Would you mind to use 4 whitespace characters to indent the code?

src/command.c Outdated
int cmd_time(struct command *cmd)
{
struct timeval tm;
int ret = gettimeofday(&tm, NULL);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys/time.h should be included.

@maralla maralla merged commit 93a450e into eleme:master May 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants