Merge pull request #3454 from alanbarr/cppcheck_fixes_2

Cppcheck Fixes
This commit is contained in:
Orestis 2018-10-13 21:07:17 +03:00 committed by GitHub
commit 565d38c5af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -44,10 +44,7 @@ int mkdirp(const char *path, mode_t mode) {
char *sep = strrchr(copy, '/'); char *sep = strrchr(copy, '/');
if (sep == NULL) { if (sep == NULL) {
if (copy != NULL) {
free(copy); free(copy);
copy = NULL;
}
return -1; return -1;
} }
*sep = '\0'; *sep = '\0';

View File

@ -70,7 +70,7 @@ ssize_t writeall(int fd, const void *buf, size_t count) {
size_t written = 0; size_t written = 0;
while (written < count) { while (written < count) {
const ssize_t n = write(fd, buf + written, count - written); const ssize_t n = write(fd, ((char *)buf) + written, count - written);
if (n == -1) { if (n == -1) {
if (errno == EINTR || errno == EAGAIN) if (errno == EINTR || errno == EAGAIN)
continue; continue;
@ -86,7 +86,7 @@ ssize_t writeall_nonblock(int fd, const void *buf, size_t count) {
size_t written = 0; size_t written = 0;
while (written < count) { while (written < count) {
const ssize_t n = write(fd, buf + written, count - written); const ssize_t n = write(fd, ((char *)buf) + written, count - written);
if (n == -1) { if (n == -1) {
if (errno == EAGAIN) { if (errno == EAGAIN) {
return written; return written;