Better code style to remove warnings

This commit is contained in:
Night Kaly 2024-09-25 11:00:39 +01:00
parent d4b5a20c17
commit 318b447cb9
Signed by: night0721
GPG key ID: 957D67B8DB7A119B
2 changed files with 12 additions and 4 deletions

View file

@ -86,8 +86,16 @@ keypair_t *get_keypair(char *username)
}
uint8_t pk[PK_SIZE], sk[SK_SIZE];
fread(pk, 1, PK_SIZE, keyf);
fread(sk, 1, SK_SIZE, keyf);
size_t bytes_read;
bytes_read = fread(pk, 1, PK_SIZE, keyf);
if (bytes_read != PK_SIZE) {
error(1, "Error reading public key from file, bytes_read(%zu)!=%d", bytes_read, PK_SIZE);
}
bytes_read = fread(sk, 1, SK_SIZE, keyf);
if (bytes_read != SK_SIZE) {
error(1, "Error reading secret key from file, bytes_read(%zu)!=%d", bytes_read, SK_SIZE);
}
fclose(keyf);
keypair_t *kp = memalloc(sizeof(keypair_t));

View file

@ -94,11 +94,11 @@ void mkdir_p(const char *file)
snprintf(path, PATH_MAX, "%s%s", home, file + 1);
} else {
strcpy(path, file);
}
}
/* fix first / not appearing in the string */
if (path[0] == '/')
strcat(dir_path, "/");
strcat(dir_path, "/");
/* Find last occurrence of '/' */
char *last_slash = strrchr(path, '/');