Timo Aaltonen pushed to branch upstream-unstable at X Strike Force / lib / libinput
Commits: 2189fd2c by Peter Hutterer at 2020-03-18T15:29:50+10:00 tools: record: fix dmi recording Processing os-release in the same buffer that the dmi modalias used caused the dmi to be recorded as 'dmi: "VERSION_ID=31"'. The cause for that was simply that the dmi modalias was read but not printed until after the os-release information was processed. Fix this two-fold: rearrange that each part now reads and prints in one go, and rename the buffers so we don't re-use them. Signed-off-by: Peter Hutterer <[email protected]> (cherry picked from commit 850925910f7f6db16f0aa645892d9121760de7b2) - - - - - f7a6f751 by Peter Hutterer at 2020-03-18T15:30:25+10:00 libinput 1.15.4 Signed-off-by: Peter Hutterer <[email protected]> - - - - - 2 changed files: - meson.build - tools/libinput-record.c Changes: ===================================== meson.build ===================================== @@ -1,5 +1,5 @@ project('libinput', 'c', - version : '1.15.3', + version : '1.15.4', license : 'MIT/Expat', default_options : [ 'c_std=gnu99', 'warning_level=2' ], meson_version : '>= 0.41.0') ===================================== tools/libinput-record.c ===================================== @@ -1430,37 +1430,26 @@ print_system_header(struct record_context *ctx) struct utsname u; const char *kernel = "unknown"; FILE *dmi, *osrelease; - char buf[2048] = "unknown"; - - if (uname(&u) != -1) - kernel = u.release; - - dmi = fopen("/sys/class/dmi/id/modalias", "r"); - if (dmi) { - if (fgets(buf, sizeof(buf), dmi)) { - buf[strlen(buf) - 1] = '\0'; /* linebreak */ - } else { - sprintf(buf, "unknown"); - } - fclose(dmi); - } + char dmistr[2048] = "unknown"; iprintf(ctx, "system:\n"); indent_push(ctx); + /* /etc/os-release version and distribution name */ osrelease = fopen("/etc/os-release", "r"); if (!osrelease) osrelease = fopen("/usr/lib/os-release", "r"); if (osrelease) { char *distro = NULL, *version = NULL; + char osrstr[256] = "unknown"; - while (fgets(buf, sizeof(buf), osrelease)) { - buf[strlen(buf) - 1] = '\0'; /* linebreak */ + while (fgets(osrstr, sizeof(osrstr), osrelease)) { + osrstr[strlen(osrstr) - 1] = '\0'; /* linebreak */ - if (!distro && strneq(buf, "ID=", 3)) - distro = safe_strdup(&buf[3]); - else if (!version && strneq(buf, "VERSION_ID=", 11)) - version = safe_strdup(&buf[11]); + if (!distro && strneq(osrstr, "ID=", 3)) + distro = safe_strdup(&osrstr[3]); + else if (!version && strneq(osrstr, "VERSION_ID=", 11)) + version = safe_strdup(&osrstr[11]); if (distro && version) { iprintf(ctx, "os: \"%s:%s\"\n", distro, version); @@ -1471,8 +1460,23 @@ print_system_header(struct record_context *ctx) free(version); fclose(osrelease); } + + /* kernel version */ + if (uname(&u) != -1) + kernel = u.release; iprintf(ctx, "kernel: \"%s\"\n", kernel); - iprintf(ctx, "dmi: \"%s\"\n", buf); + + /* dmi modalias */ + dmi = fopen("/sys/class/dmi/id/modalias", "r"); + if (dmi) { + if (fgets(dmistr, sizeof(dmistr), dmi)) { + dmistr[strlen(dmistr) - 1] = '\0'; /* linebreak */ + } else { + sprintf(dmistr, "unknown"); + } + fclose(dmi); + } + iprintf(ctx, "dmi: \"%s\"\n", dmistr); indent_pop(ctx); } View it on GitLab: https://salsa.debian.org/xorg-team/lib/libinput/-/compare/a1c8909337766a85d916ffd3aba69b119f7848dd...f7a6f751dd5305911ab081a6595942c7782fed6b -- View it on GitLab: https://salsa.debian.org/xorg-team/lib/libinput/-/compare/a1c8909337766a85d916ffd3aba69b119f7848dd...f7a6f751dd5305911ab081a6595942c7782fed6b You're receiving this email because of your account on salsa.debian.org.

