summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-05-25 19:10:56 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-05-25 19:10:56 +0200
commit1474691da1ef20cc67eff291dc1c2db1512f7a4a (patch)
tree8f4e0d474f3baecbf1a26f4977589b103af2d93c
parent1c32f082b642e83a5ee1b6b3f802046a666fc707 (diff)
downloadexynos-gpio-tool-1474691da1ef20cc67eff291dc1c2db1512f7a4a.tar.gz
exynos-gpio-tool-1474691da1ef20cc67eff291dc1c2db1512f7a4a.tar.bz2
exynos-gpio-tool-1474691da1ef20cc67eff291dc1c2db1512f7a4a.zip
Fix get_board_name
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--compatible_devices.c27
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)
{