summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu-dmi.c
Commit message (Collapse)AuthorAgeFilesLines
* lscpu: prefer memcpy() to manual pointer arithmeticSami Kerola2019-07-271-1/+1
| | | | | | | | | | | With pointer arithmetic clang address sanitizer gives following error this change addresses. Notice the following happens only when running as root. sys-utils/lscpu-dmi.c:83:14: runtime error: load of misaligned address 0x55a1d62f3d1d for type 'const uint16_t' (aka 'const unsigned short'), which requires 2 byte alignment Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lscpu: move struct lscpu_desc header fileKarel Zak2018-01-221-3/+0Star
| | | | | | | The lscpu code is growing and it seems better to allow to make code more structured. Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: cleanup DMI detection return codesKarel Zak2017-06-131-8/+13
| | | | | | | | | | | | Michal wrote: There is weird mix of logic in lscpu-dmi.c which sometimes returns 0 and sometimes -1 on error. Since most checks are if (rc) goto done; this bails out early on error skipping some detection methods. Further, in lscpu.c all following detections are guarder by if(hyper) so returning -1 causes all following methods to be skipped. Reported-by: Michal Suchanek <msuchanek@suse.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: use macro for path to DMIKarel Zak2017-04-181-1/+3
| | | | | | Just to be consistent with lscpu.c. Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: use sysfs for table access if availableArd Biesheuvel2017-04-181-0/+16
| | | | | | | | | | | | | | | | | | | | | On ARM systems, accessing SMBIOS tables via /dev/mem using read() calls is not supported. The reason is that such tables are usually located in EFI_RUNTIME_SERVICE_DATA memory, which is not covered by the linear mapping on those systems, and so read() calls will fail. So instead, use the /sys/firmware/dmi/tables/DMI sysfs file, which contains the entire structure table array, and will be available on any recent Linux system, even on ones that only export the rev3 SMBIOS entry point, which is currently ignored by lscpu. Note that the max 'num' value is inferred from the size. This is not a limitation of the sysfs interface, but a limitation of the rev3 entry point, which no longer carries a number of array elements. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Alexander Graf <agraf@suse.de> Reviewed-by: Alexander Graf <agraf@suse.de>
* lscpu: fix cppcheck warningsBoris Egorov2014-09-161-1/+1
| | | | | | | | | CppCheck founds a few wrong arguments in format strings and a NULL pointer dereference. Amended version with fixed strcmp() usage. Signed-off-by: Boris Egorov <egorov@linux.com>
* lscpu: avoid double freeSami Kerola2014-07-131-1/+1
| | | | | | The double free was possible for architectures other than x86_64 or i386. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build: fix some compiler warningsRuediger Meier2014-05-301-0/+2
| | | | | | | | | | | | Most of them catched on 32bit gcc and icc. disk-utils/fsck.cramfs.c: printf format type lib/boottime.c: unused variables misc-utils/cal.c: set but never used sys-utils/losetup.c: set but never used sys-utils/lscpu-dmi.c: defined but not used sys-utils/switch_root.c: comparison between signed and unsigned tests/helpers/test_sysinfo.c: printf format type
* lscpu: read_hypervisor_dmi: only fallback to memory scan on x86/x86_64Stewart Smith2014-03-041-1/+2
| | | | | | | | | | | As the comment in the code says, this method is really only valid on x86 and x86_64, so add a #ifdef for those architectures around that code block. This was causing "Program lscpu tried to access /dev/mem between f0000->100000." warnings on some ppc64 machines. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* lscpu: cleanup DMI code [coverity scan]Karel Zak2013-10-021-36/+41
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: check strchr() result [coverity scan]Karel Zak2013-10-011-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: don't pass null pointer to string functions [coverity scan]Karel Zak2013-10-011-3/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: fix memory leak [clang-analyzer]Sami Kerola2013-07-091-1/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lscpu: detect more hypervisor vendorsOndrej Oprala2013-05-201-0/+272
[kzak@redhat.com: - cleanup coding style, - use path_exist()] Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>