1 From 14900d539c9d379a39ec157bb7e1914aad8fde3c Mon Sep 17 00:00:00 2001
2 From: Keith Packard <keithp@keithp.com>
3 Date: Thu, 3 Jan 2019 11:57:42 -0800
4 Subject: [PATCH] ao-tools/ao-cal-accel: Initialize byte count var 'l'
6 When left uninitialized, the program would randomly segfault at startup.
8 Signed-off-by: Keith Packard <keithp@keithp.com>
10 ao-tools/ao-cal-accel/ao-cal-accel.c | 62 +++-------------------------
11 1 file changed, 5 insertions(+), 57 deletions(-)
13 diff --git a/ao-tools/ao-cal-accel/ao-cal-accel.c b/ao-tools/ao-cal-accel/ao-cal-accel.c
14 index 8a9e6347..671e4ba5 100644
15 --- a/ao-tools/ao-cal-accel/ao-cal-accel.c
16 +++ b/ao-tools/ao-cal-accel/ao-cal-accel.c
17 @@ -48,35 +48,13 @@ static void usage(char *program)
23 done(struct cc_usb *cc, int code)
30 -ends_with(char *whole, char *suffix)
32 - int whole_len = strlen(whole);
33 - int suffix_len = strlen(suffix);
35 - if (suffix_len > whole_len)
37 - return strcmp(whole + whole_len - suffix_len, suffix) == 0;
41 -starts_with(char *whole, char *prefix)
43 - int whole_len = strlen(whole);
44 - int prefix_len = strlen(prefix);
46 - if (prefix_len > whole_len)
48 - return strncmp(whole, prefix, prefix_len) == 0;
53 char **strs = malloc (sizeof (char *)), *str;
54 @@ -92,16 +70,6 @@ tok(char *line) {
59 -free_strs(char **strs) {
63 - for (i = 0; (str = strs[i]) != NULL; i++)
71 @@ -130,21 +98,8 @@ flash(struct cc_usb *usb)
76 -free_flash(struct flash *b) {
89 find_flash(struct flash *b, char *word0) {
91 for (;b; b = b->next) {
92 if (strstr(b->line, word0))
94 @@ -152,7 +107,7 @@ find_flash(struct flash *b, char *word0) {
102 struct termios termios, termios_save;
103 @@ -166,12 +121,12 @@ await_key(void)
104 tcsetattr(0, TCSAFLUSH, &termios_save);
109 do_cal(struct cc_usb *usb) {
118 @@ -230,18 +185,11 @@ int
119 main (int argc, char **argv)
128 struct cc_usb *cc = NULL;
135 while ((c = getopt_long(argc, argv, "rT:D:c:s:v:", options, NULL)) != -1) {