From 39db0d3af0ff9f7c55cdee988733fb0b3c0023c4 Mon Sep 17 00:00:00 2001 From: Burt P Date: Fri, 9 Aug 2019 12:54:10 -0500 Subject: name cleanup for x86 model strings and intel pci device strings x86 CPU: * Remove (R), (TM), etc * AMD: remove redundant "X2 Dual Core", "X4 Quad Core", etc * Move vendor to front if not already * Remove speed, as the actual speed is usually right next to it * Remove "CPU", "APU", "Processor" to shorten * Compress space Intel GPU: * Remove (R) * Abbreviate "Generation": "Gen" * Remove "Processor", "Controller", and "Device" to shorten * Compress space Some examples: x86 CPU: 'AMD Turion(tm) 64 Mobile Technology ML-32' ---> 'AMD Turion 64 Mobile ML-32' 'Cyrix MediaGXtm MMXtm Enhanced' ---> 'Cyrix MediaGX MMX Enhanced' 'Transmeta(tm) Crusoe(tm) Processor TM5800' ---> 'Transmeta Crusoe TM5800' 'VIA Nano X2 L4350 @ 1.6+ GHz' ---> 'VIA Nano X2 L4350' 'AMD Athlon(tm) 64 X2 Dual-Core Processor TK-53' ---> 'AMD Athlon 64 X2 TK-53' 'Embedded AMD Opteron(tm) Processor 23KS EE' ---> 'AMD Embedded Opteron 23KS EE' 'Intel(R) Atom(TM) x5-Z8300 CPU @ 1.44GHz' ---> 'Intel Atom x5-Z8300' 'Intel(R) Pentium(R) III CPU - S 1400MHz' ---> 'Intel Pentium III - S' 'Dual Core AMD Opteron(tm) Processor 165' ---> 'AMD Dual Core Opteron 165' 'Genuine Intel(R) CPU T1350 @ 1.86GHz' ---> 'Intel T1350' 'AMD Phenom(tm) 9350e Quad-Core Processor' ---> 'AMD Phenom 9350e Quad-Core' Intel GPU: 'Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Integrated Graphics Controller' ---> 'Atom/Celeron/Pentium x5-E8000/J3xxx/N3xxx Integrated Graphics' '4th Generation Core Processor Family Integrated Graphics Controller' ---> '4th Gen Core Family Integrated Graphics' 'Mobile GM965/GL960 Integrated Graphics Controller (secondary)' ---> 'Mobile GM965/GL960 Integrated Graphics (secondary)' 'Mobile 915GM/GMS/910GML Express Graphics Controller' ---> 'Mobile 915GM/GMS/910GML Express Graphics' Also: Fix/replace the appf() and SEQ() that were peppered about. Signed-off-by: Burt P --- hardinfo/dt_util.c | 30 ++++++------------------------ hardinfo/gpu_util.c | 16 +++++++--------- hardinfo/info.c | 3 +-- hardinfo/vendor.c | 12 +++++------- 4 files changed, 19 insertions(+), 42 deletions(-) (limited to 'hardinfo') diff --git a/hardinfo/dt_util.c b/hardinfo/dt_util.c index da38fd91..2d1b60a0 100644 --- a/hardinfo/dt_util.c +++ b/hardinfo/dt_util.c @@ -27,6 +27,7 @@ #include #include "hardinfo.h" #include "dt_util.h" +#include "appf.h" static struct { char *name; int type; @@ -682,14 +683,14 @@ char *dtr_list_override(dtr_obj *obj) { src += 4; consumed += 4; l = strlen(src) + 1; /* consume the null */ str = dtr_list_str0(src, l); - ret = appf(ret, "<%s -> %s>", ph, str); + ret = appfsp(ret, "<%s -> %s>", ph, str); src += l; consumed += l; free(ph); free(str); } if (consumed < obj->length) { str = dtr_list_byte((uint8_t*)src, obj->length - consumed); - ret = appf(ret, "%s", str); + ret = appfsp(ret, "%s", str); free(str); } return ret; @@ -720,7 +721,7 @@ char *dtr_list_phref(dtr_obj *obj, char *ext_cell_prop) { ph = dtr_elem_phref(obj->dt, obj->data_int[i], 0, NULL); i++; if (ext_cells > count - i) ext_cells = count - i; ext = dtr_list_hex((obj->data_int + i), ext_cells); i+=ext_cells; - ret = appf(ret, "<%s%s%s>", + ret = appfsp(ret, "<%s%s%s>", ph, (ext_cells) ? " " : "", ext); g_free(ph); g_free(ext); @@ -748,7 +749,7 @@ char *dtr_list_interrupts(dtr_obj *obj) { while (i < count) { icells = UMIN(icells, count - i); ext = dtr_list_hex((obj->data_int + i), icells); i+=icells; - ret = appf(ret, "<%s>", ext); + ret = appfsp(ret, "<%s>", ext); } return ret; @@ -782,7 +783,7 @@ char *dtr_list_reg(dtr_obj *obj) { consumed = 0; while (consumed + (tup_len * 4) <= obj->length) { tup_str = dtr_list_hex(next, tup_len); - ret = appf(ret, "<%s>", tup_str); + ret = appfsp(ret, "<%s>", tup_str); free(tup_str); consumed += (tup_len * 4); next += tup_len; @@ -1184,22 +1185,3 @@ char *dtr_maps_info(dtr *s) { g_free(sy_map); return ret; } - -char *appf(char *src, char *fmt, ...) { - gchar *buf, *ret; - va_list args; - - va_start(args, fmt); - buf = g_strdup_vprintf(fmt, args); - va_end(args); - - if (src != NULL) { - ret = g_strdup_printf("%s%s%s", src, sp_sep(src), buf); - g_free(buf); - g_free(src); - } else - ret = buf; - - return ret; -} - diff --git a/hardinfo/gpu_util.c b/hardinfo/gpu_util.c index 17c79a73..6bf2ac2d 100644 --- a/hardinfo/gpu_util.c +++ b/hardinfo/gpu_util.c @@ -20,7 +20,7 @@ #include "hardinfo.h" #include "gpu_util.h" - +#include "nice_name.h" #include "cpu_util.h" /* for EMPIFNULL() */ nvgpu *nvgpu_new() { @@ -229,14 +229,12 @@ static void make_nice_name(gpud *s) { /* try and a get a "short name" for the vendor */ vendor_str = vendor_get_shortest_name(vendor_str); - /* These two former special cases are currently handled by the vendor_get_shortest_name() - * function well enough, but the notes are preserved here. */ - /* nvidia PCI strings are pretty nice already, - * just shorten the company name */ - // s->nice_name = g_strdup_printf("%s %s", "nVidia", device_str); - /* Intel Graphics may have very long names, like "Intel Corporation Seventh Generation Something Core Something Something Integrated Graphics Processor Revision Ninety-four" - * but for now at least shorten "Intel Corporation" to just "Intel" */ - // s->nice_name = g_strdup_printf("%s %s", "Intel", device_str); + if (strstr(vendor_str, "Intel")) { + gchar *device_str_clean = strdup(device_str); + nice_name_intel_gpu_device(device_str_clean); + s->nice_name = g_strdup_printf("%s %s", vendor_str, device_str_clean); + g_free(device_str_clean); + } if (strstr(vendor_str, "AMD")) { /* AMD PCI strings are crazy stupid because they use the exact same diff --git a/hardinfo/info.c b/hardinfo/info.c index ac18e0d9..cf6af9f9 100644 --- a/hardinfo/info.c +++ b/hardinfo/info.c @@ -17,6 +17,7 @@ */ #include "hardinfo.h" +#include "util_sysobj.h" /* for SEQ() */ /* Using a slightly modified gg_key_file_parse_string_as_value() * from GLib in flatten(), to escape characters and the separator. @@ -377,8 +378,6 @@ gchar *info_flatten(struct Info *info) return g_string_free(values, FALSE); } -#define SEQ(a,b) (g_strcmp0(a,b) == 0) - struct InfoField *info_find_field(struct Info *info, const gchar *tag, const gchar *name) { struct InfoGroup *group; struct InfoField *field; diff --git a/hardinfo/vendor.c b/hardinfo/vendor.c index bd2642d8..5df57c52 100644 --- a/hardinfo/vendor.c +++ b/hardinfo/vendor.c @@ -26,9 +26,7 @@ #include "config.h" #include "hardinfo.h" #include "strstr_word.h" - -#include "dt_util.h" /* for appf() */ -#define SEQ(a,b) (g_strcmp0(a,b) == 0) +#include "util_sysobj.h" /* for appfsp() and SEQ() */ /* { match_string, match_rule, name, url } */ static Vendor vendors_builtin[] = { @@ -347,14 +345,14 @@ const Vendor *vendor_match(const gchar *id_str, ...) { if (id_str) { c++; tl += strlen(id_str); - tmp = appf(tmp, "%s", id_str); + tmp = appfsp(tmp, "%s", id_str); va_start(ap, id_str); p = va_arg(ap, gchar*); while(p) { c++; tl += strlen(p); - tmp = appf(tmp, "%s", p); + tmp = appfsp(tmp, "%s", p); p = va_arg(ap, gchar*); } va_end(ap); @@ -506,14 +504,14 @@ vendor_list vendors_match(const gchar *id_str, ...) { if (id_str) { c++; tl += strlen(id_str); - tmp = appf(tmp, "%s", id_str); + tmp = appfsp(tmp, "%s", id_str); va_start(ap, id_str); p = va_arg(ap, gchar*); while(p) { c++; tl += strlen(p); - tmp = appf(tmp, "%s", p); + tmp = appfsp(tmp, "%s", p); p = va_arg(ap, gchar*); } va_end(ap); -- cgit v1.2.3