fixed small bugs

This commit is contained in:
Timerix 2025-11-21 13:20:59 +05:00
parent 806f0359d0
commit 9dc7de1b41
5 changed files with 18 additions and 9 deletions

2
dependencies/tlibc vendored

@ -1 +1 @@
Subproject commit 225a48a8d98fb5ba7edf80e882a8ae2c40852407 Subproject commit 0b4574b53e7798c6197a2e6af6300a7e64ad7d06

View File

@ -84,7 +84,7 @@ Result(void) ClientCLI_run(ClientCLI* self) {
if(com_result.error){ if(com_result.error){
Error_addCallPos(com_result.error, ErrorCallPos_here()); Error_addCallPos(com_result.error, ErrorCallPos_here());
str e_str = Error_toStr(com_result.error); str e_str = Error_toStr(com_result.error);
printf(FMT_str"\n", e_str.size, e_str.data); printf("\n"FMT_str"\n", e_str.size, e_str.data);
str_free(e_str); str_free(e_str);
Error_free(com_result.error); Error_free(com_result.error);
} }

View File

@ -6,7 +6,12 @@
#include <unistd.h> #include <unistd.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <termios.h> #include <termios.h>
#define try_zero_errno(EXPR) if((EXPR) != 0) { Return RESULT_ERROR_FMT(#EXPR " failed with errno: %s", strerror(errno)); } #define try_zero_errno(EXPR) if((EXPR) != 0) { \
char* errno_s = strerror_malloc(errno); \
ResultVar(void) err = RESULT_ERROR_FMT(#EXPR " failed with errno: %s", strerror(errno)); \
free(errno_s); \
Return err; \
}
#endif #endif
Result(void) term_init(){ Result(void) term_init(){
@ -88,7 +93,9 @@ Result(void) term_getSize(TerminalSize* out) {
Result(void) term_readLine(char* buf, u32 bufsize) { Result(void) term_readLine(char* buf, u32 bufsize) {
Deferral(1); Deferral(1);
try_assert(fgets(buf, bufsize, stdin) != NULL); if(fgets(buf, bufsize, stdin) == NULL){
try_stderrcode(ferror(stdin));
}
Return RESULT_VOID; Return RESULT_VOID;
} }
@ -117,7 +124,7 @@ Result(void) term_readLineHidden(char *buf, u32 bufsize) {
#endif #endif
// read line // read line
try_void(term_readLine(buf, bufsize)); try_void(term_readLine(buf, bufsize));
fputchar('\n'); fputc('\n', stdout);
Return RESULT_VOID; Return RESULT_VOID;
} }

View File

@ -106,7 +106,7 @@ static Result(bool) Table_getDirtyBit(Table* t){
} }
static u32 Table_calcEncryptedRowSize(Table* t){ static u32 Table_calcEncryptedRowSize(Table* t){
return AESBlockEncryptor_calcDstSize(t->header.row_size); return AESBlockEncryptor_calcDstSize(t->header.row_size);
} }
static Result(void) Table_calculateRowCount(Table* t){ static Result(void) Table_calculateRowCount(Table* t){
@ -307,7 +307,9 @@ Result(void) idb_getRows(Table* t, u64 id, void* dst, u64 count){
// read rows from file // read rows from file
for(u64 i = 0; i < count; i++){ for(u64 i = 0; i < count; i++){
void* row_ptr = (u8*)dst + row_size * i; void* row_ptr = (u8*)dst + row_size * i;
void* read_dst = t->header.encrypted ? t->enc_buf.data : row_ptr; void* read_dst = t->header.encrypted
? t->enc_buf.data
: row_ptr;
try_void(file_readStructsExactly(t->table_file, read_dst, row_size_in_file, 1)); try_void(file_readStructsExactly(t->table_file, read_dst, row_size_in_file, 1));
if(t->header.encrypted) { if(t->header.encrypted) {
try_void( try_void(

View File

@ -45,7 +45,7 @@ declare_RequestHandler(Register)
if(HashMap_tryGetPtr(&server->users_name_id_map, username_str) != NULL){ if(HashMap_tryGetPtr(&server->users_name_id_map, username_str) != NULL){
try_void(sendErrorMessage_f(server, log_ctx, conn, res_head, try_void(sendErrorMessage_f(server, log_ctx, conn, res_head,
LogSeverity_Warn, LogSeverity_Warn,
"Username'%s' already exists", "Username '%s' already exists",
username_str.data)); username_str.data));
Return RESULT_VOID; Return RESULT_VOID;
} }