diff options
author | Karol Lewandowski <k.lewandowsk@samsung.com> | 2024-01-23 12:58:00 +0100 |
---|---|---|
committer | Karol Lewandowski <k.lewandowsk@samsung.com> | 2024-01-23 12:58:00 +0100 |
commit | cbab226a74fbaaa43220dee80e8435555c6506ce (patch) | |
tree | 1bbd14ec625ea85d0bcc32232d51c1f71e2604d2 /coverity | |
parent | 44a3c2255bc480c82f34db156553a595606d8a0b (diff) | |
download | device-mapper-upstream.tar.gz device-mapper-upstream.tar.bz2 device-mapper-upstream.zip |
Imported Upstream version 2.03.22upstream/libdevmapper-1.02.196upstream/2.03.22upstreamsandbox/klewandowski/upstream_2.03.22
Diffstat (limited to 'coverity')
-rw-r--r-- | coverity/coverity_model.c | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/coverity/coverity_model.c b/coverity/coverity_model.c new file mode 100644 index 0000000..a6840a6 --- /dev/null +++ b/coverity/coverity_model.c @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * Coverity usage: + * + * translate model into xml + * cov-make-library -of coverity_model.xml coverity_model.c + * + * compile (using outdir 'cov'): + * cov-build --dir=cov make CC=gcc + * + * analyze (agressively, using 'cov') + * cov-analyze --dir cov --wait-for-license --hfa --concurrency --enable-fnptr --enable-constraint-fpp --security --all --aggressiveness-level=high --field-offset-escape --user-model-file=coverity/coverity_model.xml + * + * generate html output (to 'html' from 'cov'): + * cov-format-errors --dir cov --html-output html + */ + +struct lv_segment; +struct logical_volume; + +struct lv_segment *first_seg(const struct logical_volume *lv) +{ + return ((struct lv_segment **)lv)[0]; +} + +struct lv_segment *last_seg(const struct logical_volume *lv) +{ + return ((struct lv_segment **)lv)[0]; +} + +const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile *profile) +{ + return "STRING"; +} + +/* +struct logical_volume *origin_from_cow(const struct logical_volume *lv) +{ + if (lv) + return lv; + + __coverity_panic__(); +} +*/ + +/* simple_memccpy() from glibc */ +void *memccpy(void *dest, const void *src, int c, size_t n) +{ + const char *s = src; + char *d = dest; + + while (n-- > 0) + if ((*d++ = *s++) == (char) c) + return d; + + return 0; +} + +/* + * 2 lines bellow needs to be placed in coverity/config/user_nodefs.h + * Not sure about any other way. + * Without them, coverity shows warning since x86 system header files + * are using inline assembly to reset fdset + */ +//#nodef FD_ZERO model_FD_ZERO +//void model_FD_ZERO(void *fdset); + +void model_FD_ZERO(void *fdset) +{ + unsigned i; + + for (i = 0; i < 1024 / 8 / sizeof(long); ++i) + ((long*)fdset)[i] = 0; +} + + +/* Resent Coverity reports quite weird errors... */ +int *__errno_location(void) +{ +} +const unsigned short **__ctype_b_loc (void) +{ +} + + + +/* + * Added extra pointer check to not need these models, + * for now just keep then in file + */ + +/* +struct cmd_context; +struct profile; + +const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile *profile) +{ + return "text"; +} + +const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id, struct profile *profile) +{ + return "text"; +} +*/ + +/* + * Until fixed coverity case# 00531860: + * A FORWARD_NULL false positive on a recursive function call + * + * model also these functions: + */ +/* +const struct dm_config_node; +const struct dm_config_node *find_config_tree_array(struct cmd_context *cmd, int id, struct profile *profile) +{ + const struct dm_config_node *cn; + + return cn; +} + +const struct dm_config_node *find_config_tree_node(struct cmd_context *cmd, int id, struct profile *profile) +{ + const struct dm_config_node *cn; + + return cn; +} + +int find_config_tree_bool(struct cmd_context *cmd, int id, struct profile *profile) +{ + int b; + + return b; +} +*/ |