summaryrefslogtreecommitdiffstats
path: root/lib/cpuset.c
Commit message (Collapse)AuthorAgeFilesLines
* taskset: fix cpuset list parserKarel Zak2019-03-201-8/+24
| | | | | | | | | | | | | | | taskset hangs when executed with badly formatted cpuset list, for example: $ taskset -c 0--1 true The current cpuset list parser is pretty weak as based on scanf() without strings verification ("-1" as input for "%u" returns unexpected number). It seems faster and better to use strtoul() and isdigit(). Addresses: https://github.com/karelzak/util-linux/issues/77 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: simplify cpuset if clauses that returnSami Kerola2017-06-141-7/+5Star
| | | | | | | | There is no need for 'else' when 'if' will return. In same go move call of tolower() to last possible moment in char_to_val(), a lot of time hex values should hit 0-9 range, and it can be omitted. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/cpuset: stop changing variable that is not readSami Kerola2017-04-011-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* tests: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-03-171-4/+4
| | | | | | Likewise commit 87918040658f2fa9b1bf78f1f8f4f5c065a2e3a3. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib: use unique ifdefs for testsKarel Zak2017-01-041-1/+1
| | | | | | | Let's use unique TEST_PROGRAM_<NAME> ifdefs to make build system more robust. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: safer (and uniform) handling of return valueYuriy M. Kaminskiy2016-03-071-5/+2Star
| | | | | | When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow. Signed-off-by: Karel Zak <kzak@redhat.com>
* sys-utils/disk-utils/lib: fix printf format types [cppcheck]Boris Egorov2015-06-251-3/+3
| | | | | | Fix 'invalidPrintfArgType' cppcheck warnings Signed-off-by: Boris Egorov <egorov@linux.com>
* tests: fix memory leak [AddressSanitizer]Sami Kerola2014-11-181-0/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: cleanup copyright headersKarel Zak2013-01-081-0/+3
| | | | | | | We use the code from include/ and lib/ on many places, so use public domain if possible or LGPL for code copied from libs. Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix non-Linux buildSamuel Thibault2012-08-131-0/+2
| | | | | | | | | | | | loopdev.c, test_pager, and get_max_number_of_cpus() are linux-specific. get_linux_version will only work on Linux, let's introduce system_supports_ext4_ext2() which assumes that mounting ext2 with ext4 is not supported on non-Linux systems. [kzak@redhat.com: - use #ifdef SYS_sched_getaffinity rather than __linux__] Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib,cpuset: fix compiler warning [-Wuninitialized]Karel Zak2011-09-101-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chcpu,cpuset: reduce code duplication for cpu list parsingHeiko Carstens2011-09-101-1/+6
| | | | | | | Reduce code duplication and print better error message if an unsupported cpu number was passed. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* lib,cpuset: enforce stricter parsing of cpu listsHeiko Carstens2011-09-101-4/+8
| | | | | | | | | | The current cpulist_parse() function ignores extra non-parsable characters at the end of the to be parsed cpu list string. E.g. it would accept something like "0bla" and just set bit 0 in the cpu set. Since such a string is invalid implement stricter parsing that makes sure that everything of the string has been succesfully parsed. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* lib,cpuset: fix stride handling in cpulist_parse()Heiko Carstens2011-09-101-0/+2
| | | | | | | | If cpulist_parse() gets passed a cpu list with a stride value of 0 it will be stuck in an endless loop. E.g. the following cpu list will cause an endless loop: "0-2:0". Fix this by causing a parse error if the stride value is 0. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* lib,cpuset: fix odd placed braces in cpulist_parse()Heiko Carstens2011-09-101-2/+2
| | | | | | | | The opening and closing braces for two following if statements within cpulist_parse() are placed in an odd manner. Just fix this to prevent broken code in the future. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* lib,cpuset: fix comments for cpu mask/list functionsHeiko Carstens2011-09-101-2/+2
| | | | | | | The comments for cpumask_parse() and cpulist_parse() each describe the wrong function. Just exchange the comments. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* cpuset: add option to allow cpulist_parse() to failHeiko Carstens2011-08-151-2/+5
| | | | | | | | | | | | | This is a preparation patch for chcpu. If a cpu should be added to a cpu_set where the cpu doesn't fit into the cpu_set this got silently ignored. Since the cpu-list is user space provided it should be checked if cpus are specified that are completely out of range of the system. In order to do that add a parameter which specifies if cpulist_parse() should fail if it parses a cpu-list with "impossible" cpus. The current callers have been converted so they behave like before. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* lib: [cpuset.c] fix compiler warnings [-Wsign-compare]Karel Zak2011-08-011-9/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* move struct option to .rodataKarel Zak2011-03-031-1/+1
| | | | | | | It does not make sense to have writable large arrays of "struct option" on the stack. Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: [cpuset] call free() for rangeKarel Zak2011-02-171-0/+1
| | | | | | | | The free() before exit() is not so important, but let's keep the example code nice and consistent. Reported-by: Steve Grubb <sgrubb@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-1/+1
| | | | | | | | Solaris lacks err, errx, warn and warnx. This also means the err.h header doesn't exist. Removed err.h include from all files, and included err.h from c.h instead if it exists, otherwise alternatives are provided. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* remove duplicate includesKarel Zak2011-01-041-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* taskset: move NR_CPUS determination to lib/cpuset.cKarel Zak2010-06-011-1/+40
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: add fallback for libc (uClibc) without CPU_ALLOCKarel Zak2010-06-011-0/+33
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* taskset: use libc based cpu_set_tKarel Zak2010-06-011-109/+106Star
| | | | | | | The glibc already supports dynamically allocated CPU sets. We don't have to maintains our private non-compatible implementation. Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: add cpuset regression testKarel Zak2010-06-011-0/+70
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* taskset: move bitmap routines to lib/cpuset.cKarel Zak2010-06-011-0/+241
Signed-off-by: Karel Zak <kzak@redhat.com>