Browse Source

Fix warnings

Serj Kalichev 1 year ago
parent
commit
1b7ecb4648
6 changed files with 40 additions and 18 deletions
  1. 1 1
      Makefile.am
  2. 11 0
      bin/klish/interactive.c
  3. 1 1
      tinyrl/tinyrl.h
  4. 24 13
      tinyrl/tinyrl/keys.c
  5. 1 1
      tinyrl/tinyrl/private.h
  6. 2 2
      tinyrl/tinyrl/tinyrl.c

+ 1 - 1
Makefile.am

@@ -14,7 +14,7 @@ if TESTC
 TESTC_CFLAGS = -DTESTC
 endif
 
-AM_CFLAGS = -Wall $(DEBUG_CFLAGS) $(TESTC_CFLAGS)
+AM_CFLAGS = -Wall -Wextra $(DEBUG_CFLAGS) $(TESTC_CFLAGS)
 AM_LDFLAGS = -z relro -z now -z defs
 
 bin_PROGRAMS =

+ 11 - 0
bin/klish/interactive.c

@@ -186,6 +186,11 @@ static bool_t stdin_cb(faux_eloop_t *eloop, faux_eloop_type_e type,
 
 	tinyrl_read(ctx->tinyrl);
 
+	// Happy compiler
+	eloop = eloop;
+	type = type;
+	associated_data = associated_data;
+
 	return BOOL_TRUE;
 }
 
@@ -212,6 +217,8 @@ static bool_t tinyrl_key_enter(tinyrl_t *tinyrl, unsigned char key)
 	tinyrl_reset_line(tinyrl);
 	tinyrl_set_busy(tinyrl, BOOL_TRUE);
 
+	key = key; // Happy compiler
+
 	return BOOL_TRUE;
 }
 
@@ -226,6 +233,8 @@ static bool_t tinyrl_key_tab(tinyrl_t *tinyrl, unsigned char key)
 
 	tinyrl_set_busy(tinyrl, BOOL_TRUE);
 
+	key = key; // Happy compiler
+
 	return BOOL_TRUE;
 }
 
@@ -240,6 +249,8 @@ static bool_t tinyrl_key_help(tinyrl_t *tinyrl, unsigned char key)
 
 	tinyrl_set_busy(tinyrl, BOOL_TRUE);
 
+	key = key; // Happy compiler
+
 	return BOOL_TRUE;
 }
 

+ 1 - 1
tinyrl/tinyrl.h

@@ -104,7 +104,7 @@ size_t tinyrl_equal_part(const tinyrl_t *tinyrl,
 
 
 bool_t tinyrl_line_insert(tinyrl_t *tinyrl, const char *text, size_t len);
-bool_t tinyrl_line_delete(tinyrl_t *tinyrl, off_t start, size_t len);
+bool_t tinyrl_line_delete(tinyrl_t *tinyrl, size_t start, size_t len);
 bool_t tinyrl_line_replace(tinyrl_t *tinyrl, const char *text);
 
 

+ 24 - 13
tinyrl/tinyrl/keys.c

@@ -76,9 +76,11 @@ bool_t tinyrl_key_kill(tinyrl_t *tinyrl, unsigned char key)
 
 	// delete the text to the end of the line 
 	tinyrl_delete_text(tinyrl, tinyrl->point, tinyrl->end);
-	// keep the compiler happy 
-	key = key;
 */
+	// Happy compiler
+	tinyrl = tinyrl;
+	key = key;
+
 	return BOOL_TRUE;
 }
 
@@ -91,9 +93,11 @@ bool_t tinyrl_key_yank(tinyrl_t *tinyrl, unsigned char key)
 		// insert the kill string at the current insertion point 
 		result = tinyrl_insert_text(tinyrl, tinyrl->kill_string);
 	}
-	// keep the compiler happy 
-	key = key;
 */
+	// Happy compiler
+	tinyrl = tinyrl;
+	key = key;
+
 	return result;
 }
 
@@ -130,6 +134,8 @@ bool_t tinyrl_key_up(tinyrl_t *tinyrl, unsigned char key)
 		return BOOL_TRUE;
 	tinyrl_line_replace(tinyrl, str);
 
+	key = key; // Happy compiler
+
 	return BOOL_TRUE;
 }
 
@@ -145,6 +151,8 @@ bool_t tinyrl_key_down(tinyrl_t *tinyrl, unsigned char key)
 		return BOOL_TRUE;
 	tinyrl_line_replace(tinyrl, str);
 
+	key = key; // Happy compiler
+
 	return BOOL_TRUE;
 }
 
@@ -236,10 +244,11 @@ bool_t tinyrl_key_backword(tinyrl_t *tinyrl, unsigned char key)
         tinyrl_key_backspace(tinyrl, KEY_BS);
 
 	result = BOOL_TRUE;
-
-	// keep the compiler happy 
-	key = key;
 */
+	// Happy compiler
+	tinyrl = tinyrl;
+	key = key;
+
 	return result;
 }
 
@@ -278,11 +287,11 @@ bool_t tinyrl_key_erase_line(tinyrl_t *tinyrl, unsigned char key)
 	// delete the text from the start of the line 
 	tinyrl_delete_text(tinyrl, 0, end);
 	tinyrl->point = 0;
-
-	// keep the compiler happy 
-	key = key;
-	tinyrl = tinyrl;
 */
+	// Happy compiler
+	tinyrl = tinyrl;
+	key = key;
+
 	return BOOL_TRUE;
 }
 
@@ -306,8 +315,10 @@ bool_t tinyrl_key_tab(tinyrl_t *tinyrl, unsigned char key)
 		// oops don't change the result and let the bell ring 
 		break;
 	}
-	// keep the compiler happy 
-	key = key;
 */
+	// Happy compiler
+	tinyrl = tinyrl;
+	key = key;
+
 	return result;
 }

+ 1 - 1
tinyrl/tinyrl/private.h

@@ -42,7 +42,7 @@ typedef struct line_s {
 	char *str;
 	size_t size; // Size of buffer
 	size_t len; // Length of string
-	off_t pos;
+	size_t pos;
 } line_t;
 
 #define NUM_HANDLERS 256

+ 2 - 2
tinyrl/tinyrl/tinyrl.c

@@ -340,7 +340,7 @@ static bool_t process_char(tinyrl_t *tinyrl, char key)
 	// Continue ESC sequence
 	if (tinyrl->esc_cont) {
 		// Broken sequence. Too long
-		if ((tinyrl->esc_p - tinyrl->esc_seq) >= (sizeof(tinyrl->esc_seq) - 1)) {
+		if ((tinyrl->esc_p - tinyrl->esc_seq) >= (long int)(sizeof(tinyrl->esc_seq) - 1)) {
 			tinyrl->esc_cont = BOOL_FALSE;
 			return BOOL_FALSE;
 		}
@@ -526,7 +526,7 @@ bool_t tinyrl_line_insert(tinyrl_t *tinyrl, const char *text, size_t len)
 }
 
 
-bool_t tinyrl_line_delete(tinyrl_t *tinyrl, off_t start, size_t len)
+bool_t tinyrl_line_delete(tinyrl_t *tinyrl, size_t start, size_t len)
 {
 	if (start >= tinyrl->line.len)
 		return BOOL_TRUE;