Merged
Conversation
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); |
Contributor
There was a problem hiding this comment.
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);
Contributor
Author
There was a problem hiding this comment.
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
Contributor
|
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); |
Contributor
There was a problem hiding this comment.
sys/time.h should be included.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fork using lastest code