diff options
| -rw-r--r-- | compatible_devices.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/compatible_devices.c b/compatible_devices.c index 7dcace6..dd82b29 100644 --- a/compatible_devices.c +++ b/compatible_devices.c @@ -15,6 +15,8 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +#define _GNU_SOURCE + #include <errno.h> #include <fcntl.h> #include <stdio.h> @@ -42,18 +44,30 @@ static char *get_board_name(int debug, char *buf) printf("%s: 'H' not found, exiting.\n", __func__); /* Not found */ return NULL; + } else { + if (debug) + printf("%s: found 'H' at <%s>\n", + __func__, start); } buf = start; /* Look for "Hardware : " in "Hardware : SMDK4x12" */ - if (strcmp(start, "Hardware\t: ")) { + if (strncmp(start, "Hardware\t: ", strlen("Hardware\t: "))) { + if (debug) + printf("%s: \"Hardware\" not found at <%s>\n", + __func__, start); /* Start after the 'H' next time */ buf += 1; continue; + } else { + if (debug) + printf("%s: Found \"Hardware\" at <%s>\n", + __func__, start); } buf += strlen("Hardware\t: "); + start += strlen("Hardware\t: "); end = strchr(buf, '\n'); if (end == NULL) { @@ -63,6 +77,10 @@ static char *get_board_name(int debug, char *buf) __func__); /* Not found */ return NULL; + } else { + if (debug) + printf("%s: Found end of line at <%s>\n", + __func__, end); } /* Found */ @@ -83,9 +101,14 @@ static char *get_board_name(int debug, char *buf) result[end - start] = '\0'; + if (debug) + printf("%s: found Hardware: %s\n", __func__, result); + + return result; + } while (true); - return result; + return NULL; } static int board_is_compatible(int debug) { |
