mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 05:53:40 +00:00
[common] cpuinfo: trim any trailing whitespace from CPU model
This commit is contained in:
parent
977a4f6323
commit
5fc561fa63
@ -25,6 +25,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores)
|
bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores)
|
||||||
{
|
{
|
||||||
@ -51,7 +52,13 @@ bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores)
|
|||||||
const char * name = strstr(buffer, ": ");
|
const char * name = strstr(buffer, ": ");
|
||||||
if (name)
|
if (name)
|
||||||
name += 2;
|
name += 2;
|
||||||
snprintf(model, modelSize, "%s", name ? name : "Unknown");
|
int len = snprintf(model, modelSize, "%s", name ? name : "Unknown");
|
||||||
|
|
||||||
|
// trim any whitespace
|
||||||
|
while(len > 0 && isspace(model[len-1]))
|
||||||
|
--len;
|
||||||
|
model[len] = '\0';
|
||||||
|
|
||||||
model = NULL;
|
model = NULL;
|
||||||
}
|
}
|
||||||
else if (cores && strncmp(buffer, "cpu cores", 9) == 0)
|
else if (cores && strncmp(buffer, "cpu cores", 9) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user