Joachim Wiberg
April 18, 2019
git blamegit diff before commit
Remember: please avoid internal references and customer names in
Open Source patches or in GitHub commit messages, comments …
| Dangeours | Recommended | Comment |
|---|---|---|
sprintf() |
snprintf() |
POSIX.1-2001, POSIX.1-2008, C99 |
strcpy()/strncpy() |
strlcpy() |
Available in -lite, notice length differs |
strcat() |
strlcat() |
– " – |
gets(), fread() |
fgets() |
POSIX.1-2001, C89 |
memcpy() |
memmove() |
POSIX.1-2001, C89, SVr4, 4.3BSD |
time() |
sysinfo() → si.uptime |
For relative time |
clock_gettime() |
CLOCK_MONOTONIC or CLOCK_BOOTTIME | |
gettimeofday() |
Same as above, unless wall time is intended | |
Avoid commenting on everything
Less focus on what the code does; we can also read code …
More focus on why; “Speed change does not bite without PHY reset, see errata N.YY”
Can you refactor the code to make it more readable?
“Add file”
“Weekly commit”
First-line summary is short, typically <60 chars
Add your findings and reasoning/why to the body, after an empty newline.
This helps tools like "git format-patch" and is generally considererd to
be good form. Here you can also add references to other issues.
Remember: for open source or external systems, avoid internal references!
Take pride in your work, sign-off on it.
Signed-off-by: User Nameson <user.nameson@example.com>
For details, see the kernel Developer’s Certificate of Origin