Skip to content

Commit f63ca72

Browse files
committed
Change if statements checking for asserts
1 parent e332a02 commit f63ca72

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

src/commands.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,21 @@ static const LacoCommand line_commands[] = {
4747
/* External API */
4848

4949
void laco_handle_command(struct LacoState* laco, char* line) {
50-
if(laco != NULL && line != NULL) {
51-
char* command_line = strdup(line + 1);
52-
char** command_words = laco_line_to_words(command_line);
50+
assert(laco != NULL);
51+
assert(line != NULL);
52+
53+
char* command_line = strdup(line + 1);
54+
char** command_words = laco_line_to_words(command_line);
5355

54-
/* Alias for parsed out words within the line */
55-
const char* command = command_words[0];
56-
const char** arguments = (const char**) command_words + 1;
56+
/* Alias for parsed out words within the line */
57+
const char* command = command_words[0];
58+
const char** arguments = (const char**) command_words + 1;
5759

58-
laco_dispatch(line_commands, laco, command, arguments);
60+
laco_dispatch(line_commands, laco, command, arguments);
5961

60-
free(command_line);
61-
free(command_words);
62+
free(command_line);
63+
free(command_words);
6264

63-
/* Make it seems like this was an empty line */
64-
line[0] = '\0';
65-
}
65+
/* Make it seems like this was an empty line */
66+
line[0] = '\0';
6667
}

src/laco.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int laco_get_laco_status(LacoState* laco) {
7676
}
7777

7878
void laco_set_laco_status(LacoState* laco, int status) {
79-
if(laco != NULL) {
80-
laco->status = status;
81-
}
79+
assert(laco != NULL);
80+
81+
laco->status = status;
8282
}

src/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool laco_is_match(const char** matches, const char* test_string) {
4747

4848
char** laco_split_by(const char split_with, char* string,
4949
int ignore_repeats) {
50-
if(string == NULL) return NULL;
50+
assert(string != NULL);
5151

5252
char** result = calloc(16, sizeof(char*));
5353
size_t i = 0;

0 commit comments

Comments
 (0)