Skip to content

Commit

Permalink
enforced int->uint32 where possible. removed extra code found by -Wall
Browse files Browse the repository at this point in the history
  • Loading branch information
reginaldford committed Nov 23, 2024
1 parent 0466df4 commit e4b71fe
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 69 deletions.
109 changes: 54 additions & 55 deletions src/main/engine/sm_ast_engine.c

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/main/memory/sm_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ sm_object *sm_move_to_new_heap(sm_heap *dest, sm_object *obj) {
uint32_t sizeOfObj = sm_sizeof(obj);
sm_object *new_obj = sm_realloc_at(dest, obj, sizeOfObj);
// Overwrite the old object. sm_pointer objects
intptr_t endPoint = (intptr_t)obj + sizeOfObj;
sm_new_pointer(dest, obj, new_obj);
return new_obj;
}
Expand Down
1 change: 0 additions & 1 deletion src/main/object/sm_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ uint32_t sm_ui8_array_contents_sprint(sm_array *array, char *buffer, bool fake)


uint32_t sm_array_contents_sprint(sm_array *a, char *buffer, bool fake) {
uint32_t cursor = 0;
switch (a->inner_type) {
case SM_F64_TYPE: {
return sm_f64_array_contents_sprint(a, buffer, fake);
Expand Down
6 changes: 3 additions & 3 deletions src/main/object/sm_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ sm_error *sm_new_error(int title_len, char *title_str, int message_len, char *me
new_error->source = sourceStr;
new_error->line = line;
// Run the error handler if it exists
sm_cx *scratch = *sm_global_lex_stack(NULL)->top;
sm_fun *fun = (sm_fun *)sm_cx_get_far(scratch, sm_new_symbol("_errHandler", 11));
sm_expr *sf = sm_new_expr(SM_PARAM_LIST_EXPR, (sm_object *)new_error, NULL);
// sm_cx *scratch = *sm_global_lex_stack(NULL)->top;
// sm_fun *fun = (sm_fun *)sm_cx_get_far(scratch, sm_new_symbol("_errHandler", 11));
// sm_expr *sf = sm_new_expr(SM_PARAM_LIST_EXPR, (sm_object *)new_error, NULL);
new_error->notes = NULL;
return new_error;
}
Expand Down
1 change: 0 additions & 1 deletion src/main/parser/sms.y
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,6 @@ CONTEXT_LIST : '{' ASSOCIATION ';' ASSOCIATION {
$$ = new_cx;
}
| CONTEXT_LIST ';' ASSOCIATION {
sm_string *name = ((sm_symbol *)sm_expr_get_arg($3, 0))->name;
sm_object *value = (sm_object *)sm_expr_get_arg($3, 1);
sm_cx_let($1,(sm_symbol*)sm_expr_get_arg($3,0),value);
$$ = $1;
Expand Down
4 changes: 1 addition & 3 deletions src/main/sm_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ uint64_t sm_bytelength_parse(char *str, int length) {
if (current_char == 0) {
buffer[j] = 0;
// If no unit is given, assume megabytes (m)
uint64_t l = atof(buffer) * 1024 * 1024;
return (f64)atof(buffer) * 1024 * 1024;
}
if (sm_is_digit(current_char) || current_char == '.') {
Expand Down Expand Up @@ -87,8 +86,7 @@ int sm_sprint_fancy_bytelength(char *buffer, uint64_t bytelength) {

// Reads a file into a string. If there is any issue, returns sms_false
sm_string *sm_read_file(char *filePath, int filePathLen) {
sm_string *fname_str;
char *fname_cstr = filePath;
char *fname_cstr = filePath;
if (access(fname_cstr, F_OK) != 0) {
printf("fileReadStrStr failed because the file, %s ,does not exist.\n", fname_cstr);
return (sm_string *)sms_false;
Expand Down
2 changes: 0 additions & 2 deletions src/main/sm_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ sm_string *sm_global_home_directory() {
// Read only sm_string for home directory, or NULL
sm_string *sm_global_hist_file() {
static char hist_file_string_space[256];
sm_string *str = (sm_string *)hist_file_string_space;
if (!*hist_file_string_space) {
sm_env env = *sm_global_environment(NULL);
sm_string *str = (sm_string *)hist_file_string_space;
Expand All @@ -373,7 +372,6 @@ sm_string *sm_global_hist_file() {
// global version string
sm_string *sms_global_version() {
static char version_string_space[16 + sizeof(struct sm_string)];
sm_string *str = (sm_string *)version_string_space;
if (!*version_string_space) {
sm_env env = *sm_global_environment(NULL);
sm_string *str = (sm_string *)version_string_space;
Expand Down
1 change: 0 additions & 1 deletion src/main/sm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ void sm_init(sm_env *env, int num_args, char **argv) {
env->mem_bytes = mem_bytes;
// Using default history file
if (!env->no_history_file && !env->history_file_len) {
char history_path[256];
sm_string *home_dir = sm_global_home_directory();
if (home_dir) {
sprintf(env->history_file, "%s/.sms_history", &home_dir->content);
Expand Down
2 changes: 0 additions & 2 deletions src/main/terminal/sm_terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ void add_keys(sm_cx *cx, sm_expr *keys, const char *buf, int buf_len, const char
for (int i = 0; i < keys->size; i++) {
sm_symbol *sym = (sm_symbol *)sm_expr_get_arg(keys, i);
if (!strncmp(last_sym, &sym->name->content, MIN(last_sym_len, sym->name->size))) {
int completion_len = (sym->name->size) + buf_len;
sm_strncpy(concat_space + buf_len - last_sym_len, &sym->name->content, sym->name->size);
concat_space[buf_len + sym->name->size] = '\0';
linenoiseAddCompletion(lc, concat_space);
Expand Down Expand Up @@ -94,7 +93,6 @@ sm_parse_result sm_terminal_prompt_linenoise() {
escape_attempts = 0;
int len = strlen(line);
linenoiseHistoryAdd(line);
char historyFilePath;
if (!env->no_history_file)
linenoiseHistorySave(env->history_file);
int outputLen = len + 1;
Expand Down

0 comments on commit e4b71fe

Please sign in to comment.