1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

1525 Commits

Author SHA1 Message Date
Zdenek Kabelac
5561f2a530 dmsetup: reduce parser code
Switch set upfront.
Only add code, which is not common for every switch.
Use just 16bit for switch counting.
2024-05-08 16:10:52 +02:00
Zdenek Kabelac
2f3fcbd245 libdm: fix invalid conversion
Previous commit missed to also add one to added 'len'.
2024-05-08 10:16:01 +02:00
Zdenek Kabelac
4dda6d1555 libdm: stats uses overflowing counter
Here we need to annotate counter as it starts with UINT64_MAX
and overflows to 0 is expected.
2024-05-08 10:14:52 +02:00
Zdenek Kabelac
cfcbf89ed0 cov: eliminate dead code
Deduplicate code and also drop some warn about dead code.
2024-05-08 01:55:21 +02:00
Zdenek Kabelac
f0d3d0482e cov: enum health status
Cleanly map health char status to enum.
2024-05-08 01:55:21 +02:00
Zdenek Kabelac
3f41b4af55 cov: check for overlow math
Add some extre protection to avoid integer overflow type of problems.
2024-05-08 01:55:21 +02:00
Zdenek Kabelac
f6e0e7b9aa cov: sanitize input buffer
Make coverity aware the input line is legit.
Eventually add more sanitize functionality.
2024-05-08 01:55:21 +02:00
Zdenek Kabelac
4761753a6f cov: replace strcpy with memcpy 2024-05-08 01:55:21 +02:00
Zdenek Kabelac
04b407674c cov: use sscanf buffer size limits
String parsing with buffer size limit.
2024-05-08 01:55:21 +02:00
Zdenek Kabelac
e56e7ed533 libdm: unlink checks for ENOENT 2024-05-08 01:55:21 +02:00
Zdenek Kabelac
a763420786 libdm: use literal for error message
Use literals for printf messages.
2024-05-08 01:55:20 +02:00
Zdenek Kabelac
c140601cf6 const: rework conversion to enum
Easier code with string and also avoids mixing enums.
2024-05-08 01:55:20 +02:00
Zdenek Kabelac
5d573cc91d const: array of const values 2024-05-08 01:55:20 +02:00
Zdenek Kabelac
7b872bc4cd const: libdm err_fmt as string 2024-05-08 01:55:20 +02:00
Zdenek Kabelac
09426b4663 dmsetup: fix invalid loop test
Last patcheds had incorrect merging bug - fix loop test.
2024-05-04 01:53:54 +02:00
Zdenek Kabelac
d16a8f80e9 Revert "libdm: fix condition"
This reverts commit 2a1e200f7a.

Breaks some test - more analysis is needed.
2024-05-04 01:37:51 +02:00
Zdenek Kabelac
011e0672c5 dmsetup: use getopt defines
Replace 0/1 with getopts defines no/required_argument
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
2b198cd874 const: dmsetup long_options 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
8daa702880 const: dmsetup string 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
9a9db862a4 const: dmfilemapd strings 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
e0bd66b73a const: use common error path
Instead of defining  _field_selection_value_alloc_failed_msg[],
use common error path code for printing field_id.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
c9f9744f50 const: libdm cmd_data_v4 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
9247e754fe const: libdm tok_op 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
e6f46fafe7 const: use arrays of strings 2
Next set of changes.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
efe2005022 const: drop static keyword
We don't need relocatable space to store 'const' number.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
abf7c40185 const: static array
Such array can be stored  in   .rodata   section.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
2a1e200f7a libdm: fix condition
When we switch supported_reserved_types_with_range to const
gcc repots this problem:

 warning: ‘and’ of mutually exclusive equal-tests is always 0
 !(iter->type & supported_reserved_types_with_range))) {

It's not clear from the history what was the actual intention of this
internal error test, let's assume the check wanted to make sure
that when DM_REPORT_FIELD_RESERVED_VALUE_RANGE is set,
some other fields from supported_reserved_types_with_range set
are also selected.
2024-05-04 00:58:44 +02:00
Zdenek Kabelac
9b2f9d64c0 libdm: ensure suffixes list elements are const
This was rather API mistake - the internal of libdm
do handle suffixes list as const string, just the API
was only using  'const char **'.

So the user may pass safely casted 'const char * const`.
2024-05-04 00:57:52 +02:00
Zdenek Kabelac
95fca3d1d5 makefile: avoid creating shared lib for static only build 2024-04-26 21:37:51 +02:00
Zdenek Kabelac
b0c0e8bd7a makefiles: change condition
Old system do not work well with -l% in findstring,
so use a different strategy to recognize whether -lreadline needs
another library (-ltinfo, -lncourses...)
(So we don't need to solve this via 'configure')

Also for now comment out -Wl,-z,pack-relative-relocs and leave it
for the package maintainer whether they want to use.
Possibly add some 'configure' autodetection for usable switch,
as it's relatively new feature..
2024-04-25 17:06:07 +02:00
Zdenek Kabelac
b14f29ab5b makefiles: comman escape needs this trick 2024-04-24 13:42:05 +02:00
Zdenek Kabelac
a8009f72bf makefiles: add as-needed only for newer systems
Add some -Wl flags separatly and avoid their duplication.
Also add --as-needed only when system is using 'newer' readline
library - on these older system the usage of '--as-needed'
seems to be causing some hard to solve problem - so avoid it.
2024-04-24 11:35:05 +02:00
Zdenek Kabelac
078445658c configure.ac: update ldflags args
Attach -Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed
to LDFLAGS, but only if LDFLAGS already doesn't contain 'relro'
(so it's not given repeatedly).

Also start to use -z,now linkage also when building libraries
with default compilation - this avoid calling symbol resolver
while library function are using function needing resolving.

Note: Fedora or RHEL rpm building is using:
CFLAGS=$(rpm --eval %{build_cflags})
LDFLAGS=$(rpm --eval %{build_ldflags})

Also split -DUSE_SD_NOTIFY into DEFS from CFLAGS.
2024-04-24 00:31:26 +02:00
Zdenek Kabelac
f022da9e5f configure.ac: leave LDFLAGS resolving on make time
Use LDFLAGS separately with every use of CLDFLAGS and leave
this flag only for handling versioning.

This will reflect any LDFLAGS setting use during make.
2024-04-24 00:30:05 +02:00
Zdenek Kabelac
84b084c9b6 configure.ac: define DEFAULT_PROC_DIR in one place
Let's move proc into include/configure.h so this define can
be easily used across the source base.

Configure defines it - but ATM we do not provide any configure
option to change it - there should be no need to ever change it.
2024-04-15 13:38:44 +02:00
Zdenek Kabelac
fa62397ff8 cov: mask false positive
This code is somewhat complex and involves recursion and pointer
shuffling which confuses coverity here.

Let's add masking comment for this warning as there is no double
free in this code.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
e7a54c1a50 cov: use safer version with size limitation
Although there is likely not much risk of having chance of overwritting
given buffers use safer variant.
Use dm_strncpy() when just copying %s.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
3ce83f923d cov: extra pointer validation
Add few more internal errors to enusure there is no use of NULL pointers
along the code path.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
22a0cfdc05 cov: use memccpy
When we want to copy string which may not be null terminated,
replace strncpy with more correct memccpy.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
88ad83e3d6 makefiles: use SHOW 2024-04-08 14:52:23 +02:00
Zdenek Kabelac
d490572410 gcc: clear some complains
Use dm_strncpy() were possible to get rid of gcc compile warnings.
2024-04-08 14:52:23 +02:00
Zdenek Kabelac
f9fefaaabe refactor: update dm_strncpy to _dm_strncpy
For checked versions of dm_strncpy use inline wrapper _dm_strncpy.
2024-04-04 19:38:21 +02:00
Zdenek Kabelac
295e632e81 util: add _dm_strncpy
Add internal inline function wrapper for dm_strncpy().
Use it for calls where we test the result.
Avoids emitting warnings in Coverity for unchecked usage.
2024-04-04 19:37:13 +02:00
Zdenek Kabelac
5c0ade35e2 util: swap header file load order
Ensure libdevmapper is included before util.h since
we are going to add function that is using it.
TODO: maybe add include directly here...
2024-04-04 19:33:58 +02:00
Zdenek Kabelac
a98709aeae cov: validate count is bigger then 0
To avoid teoretical underflow...
2024-03-29 01:36:48 +01:00
Zdenek Kabelac
93a633092a cov: store 64b flags
Alhtough no target is currently using that many bits for their flags,
preserve the size for loaded segment internally.
2024-03-29 01:36:48 +01:00
Zdenek Kabelac
0dbd90d74e gcc: match signed integers 2024-03-27 01:11:00 +01:00
Zdenek Kabelac
8c4b8c6e27 dmsetup: refactor getopt_long usage
Shuffle code to avoid using static variable to pass parsed option.
Code is now easier to follow and also number of coverity reports
will go away.
There should be no functional change.
2024-03-26 15:58:36 +01:00
Zdenek Kabelac
50ad27a4ab reporting: reuse existing _get_field
Use already existing _get_field() function that also
slightly optimizes 'strlen()' usage.
2024-03-25 11:05:05 +01:00
Zdenek Kabelac
2eff6e1974 raid: update dm_get_status_raid
Handle mismatch of reported 'dm raid' status, where the active
raid LV can be actually showing higher numebr of raid leg devices,
that the number of shown status characters.

This can happen if the raid leg is dropped during initial
resynchronization.
2024-03-25 11:05:05 +01:00