summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-05-22 13:58:08 (GMT)
committerBrad King <brad.king@kitware.com>2023-05-22 20:51:15 (GMT)
commit48297cf770664e59283b3bf3a35a2ceab7b55f1f (patch)
tree7d71cffd7f20bb0fcf8cc4f634e75ea37f5db2af
parent91e4d27765945e27b623fbb4e3a066ee9157970a (diff)
downloadCMake-48297cf770664e59283b3bf3a35a2ceab7b55f1f.zip
CMake-48297cf770664e59283b3bf3a35a2ceab7b55f1f.tar.gz
CMake-48297cf770664e59283b3bf3a35a2ceab7b55f1f.tar.bz2
libarchive: Suppress clang-analyzer warnings
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_acl.c10
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_match.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_ppmd8.c12
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c11
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c7
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c10
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c7
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c15
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c9
10 files changed, 84 insertions, 3 deletions
diff --git a/Utilities/cmlibarchive/libarchive/archive_acl.c b/Utilities/cmlibarchive/libarchive/archive_acl.c
index ead7e36..da471a5 100644
--- a/Utilities/cmlibarchive/libarchive/archive_acl.c
+++ b/Utilities/cmlibarchive/libarchive/archive_acl.c
@@ -37,6 +37,10 @@ __FBSDID("$FreeBSD$");
#include <wchar.h>
#endif
+#ifdef __clang_analyzer__
+#include <assert.h>
+#endif
+
#include "archive_acl_private.h"
#include "archive_entry.h"
#include "archive_private.h"
@@ -1209,6 +1213,9 @@ archive_acl_from_text_w(struct archive_acl *acl, const wchar_t *text,
* to "user::rwx", etc. valid only for first field
*/
s = field[0].start;
+ #ifdef __clang_analyzer__
+ assert(s);
+ #endif
len = field[0].end - field[0].start;
if (*s == L'd' && (len == 1 || (len >= 7
&& wmemcmp((s + 1), L"efault", 6) == 0))) {
@@ -1692,6 +1699,9 @@ archive_acl_from_text_l(struct archive_acl *acl, const char *text,
* to "user::rwx", etc. valid only for first field
*/
s = field[0].start;
+ #ifdef __clang_analyzer__
+ assert(s);
+ #endif
len = field[0].end - field[0].start;
if (*s == 'd' && (len == 1 || (len >= 7
&& memcmp((s + 1), "efault", 6) == 0))) {
diff --git a/Utilities/cmlibarchive/libarchive/archive_match.c b/Utilities/cmlibarchive/libarchive/archive_match.c
index 04747b1..2de0045 100644
--- a/Utilities/cmlibarchive/libarchive/archive_match.c
+++ b/Utilities/cmlibarchive/libarchive/archive_match.c
@@ -606,6 +606,10 @@ add_pattern_from_file(struct archive_match *a, struct match_list *mlist,
return (ARCHIVE_FATAL);
}
r = archive_read_support_format_raw(ar);
+#ifdef __clang_analyzer__
+ /* Tolerate deadcode.DeadStores to avoid modifying upstream. */
+ (void)r;
+#endif
r = archive_read_support_format_empty(ar);
if (r != ARCHIVE_OK) {
archive_copy_error(&(a->archive), ar);
diff --git a/Utilities/cmlibarchive/libarchive/archive_ppmd8.c b/Utilities/cmlibarchive/libarchive/archive_ppmd8.c
index d177939..272ca4c 100644
--- a/Utilities/cmlibarchive/libarchive/archive_ppmd8.c
+++ b/Utilities/cmlibarchive/libarchive/archive_ppmd8.c
@@ -4,6 +4,10 @@ This code is based on PPMd var.I (2002): Dmitry Shkarin : Public domain */
#include "archive_platform.h"
+#ifdef __clang_analyzer__
+#include <assert.h>
+#endif
+
#include <string.h>
#include "archive_ppmd8_private.h"
@@ -337,6 +341,9 @@ static void ExpandTextArea(CPpmd8 *p)
static void SetSuccessor(CPpmd_State *p, CPpmd_Void_Ref v)
{
+ #ifdef __clang_analyzer__
+ assert(p);
+ #endif
(p)->SuccessorLow = (UInt16)((UInt32)(v) & 0xFFFF);
(p)->SuccessorHigh = (UInt16)(((UInt32)(v) >> 16) & 0xFFFF);
}
@@ -616,6 +623,11 @@ static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c
/* fixed over Shkarin's code. Maybe it could work without + 1 too. */
CPpmd_State *ps[PPMD8_MAX_ORDER + 1];
unsigned numPs = 0;
+
+#ifdef __clang_analyzer__
+ memset(ps, 0, sizeof(ps));
+#endif
+
if (!skip)
ps[numPs++] = p->FoundState;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
index 5a94ec5..c964d3f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
@@ -92,6 +92,10 @@ __FBSDID("$FreeBSD$");
#include <sys/ioctl.h>
#endif
+#ifdef __clang_analyzer__
+#include <assert.h>
+#endif
+
#include "archive.h"
#include "archive_string.h"
#include "archive_entry.h"
@@ -742,6 +746,10 @@ _archive_read_data_block(struct archive *_a, const void **buff,
else if (errno == EPERM)
flags &= ~O_NOATIME;
}
+#ifdef __clang_analyzer__
+ /* Tolerate deadcode.DeadStores to avoid modifying upstream. */
+ (void)flags;
+#endif
#endif
if (t->entry_fd < 0) {
archive_set_error(&a->archive, errno,
@@ -2347,6 +2355,9 @@ tree_pop(struct tree *t)
if (t->stack == t->current && t->current != NULL)
t->current = t->current->parent;
te = t->stack;
+ #ifdef __clang_analyzer__
+ assert(te);
+ #endif
t->stack = te->next;
t->dirname_length = te->dirname_length;
t->basename = t->path.s + t->dirname_length;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c
index 209b2a1..c66c247 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c
@@ -36,6 +36,10 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#endif
+#ifdef __clang_analyzer__
+#include <assert.h>
+#endif
+
#include "archive.h"
#include "archive_private.h"
#include "archive_read_private.h"
@@ -467,6 +471,9 @@ read_more:
if (ensure_in_buff_size(self, uudecode,
avail_in + uudecode->in_cnt) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
+ #ifdef __clang_analyzer__
+ assert(d);
+ #endif
memcpy(uudecode->in_buff + uudecode->in_cnt,
d, avail_in);
d = uudecode->in_buff;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
index 722edf1..a4d9dcf 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
@@ -42,6 +42,10 @@ __FBSDID("$FreeBSD$");
#include <cm3p/zlib.h>
#endif
+#ifdef __clang_analyzer__
+#include <assert.h>
+#endif
+
#include "archive.h"
#include "archive_entry.h"
#include "archive_entry_locale.h"
@@ -757,6 +761,9 @@ archive_read_format_7zip_read_header(struct archive_read *a,
return (ARCHIVE_FATAL);
}
symname = mem;
+ #ifdef __clang_analyzer__
+ assert(buff);
+ #endif
memcpy(symname+symsize, buff, size);
symsize += size;
}
@@ -2500,6 +2507,9 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
if ((p = header_bytes(a, 1)) == NULL)
return (-1);
ll--;
+ #ifdef __clang_analyzer__
+ (void)*p;
+ #endif
if ((ll & 1) || ll < zip->numFiles * 4)
return (-1);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
index 380cbb8..91b9187 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
@@ -3015,6 +3015,7 @@ heap_add_entry(struct archive_read *a, struct heap_queue *heap,
uint64_t file_key, parent_key;
int hole, parent;
+#ifndef __clang_analyzer__ /* It cannot see heap->files remains populated. */
/* Expand our pending files list as necessary. */
if (heap->used >= heap->allocated) {
struct file_info **new_pending_files;
@@ -3042,6 +3043,7 @@ heap_add_entry(struct archive_read *a, struct heap_queue *heap,
heap->files = new_pending_files;
heap->allocated = new_size;
}
+#endif
file_key = file->key = key;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
index 1c9a057..41d6cb2 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
@@ -35,6 +35,8 @@
#include <cm3p/zlib.h> /* crc32 */
#endif
+#include <assert.h>
+
#include "archive.h"
#ifndef HAVE_ZLIB_H
#include "archive_crc32.h"
@@ -3215,6 +3217,7 @@ parse_filter(struct archive_read *a, const uint8_t *bytes, uint16_t length, uint
num = filters->lastfilternum;
prog = filters->progs;
+ assert(num <= numprogs);
for (i = 0; i < num; i++)
prog = prog->next;
if (prog)
@@ -3320,8 +3323,10 @@ create_filter(struct rar_program_code *prog, const uint8_t *globaldata, uint32_t
filter->prog = prog;
filter->globaldatalen = globaldatalen > PROGRAM_SYSTEM_GLOBAL_SIZE ? globaldatalen : PROGRAM_SYSTEM_GLOBAL_SIZE;
filter->globaldata = calloc(1, filter->globaldatalen);
- if (!filter->globaldata)
+ if (!filter->globaldata) {
+ free(filter);
return NULL;
+ }
if (globaldata)
memcpy(filter->globaldata, globaldata, globaldatalen);
if (registers)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c
index 548da4e..aa7b861 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c
@@ -388,7 +388,7 @@ static int cdeque_init(struct cdeque* d, int max_capacity_power_of_2) {
return CDE_PARAM;
cdeque_clear(d);
- d->arr = malloc(sizeof(void*) * max_capacity_power_of_2);
+ d->arr = malloc(sizeof(*d->arr) * max_capacity_power_of_2);
return d->arr ? CDE_OK : CDE_ALLOC;
}
@@ -2942,12 +2942,23 @@ static int parse_filter(struct archive_read* ar, const uint8_t* p) {
if(filter_type == FILTER_DELTA) {
int channels;
- if(ARCHIVE_OK != (ret = read_consume_bits(ar, rar, p, 5, &channels)))
+ if(ARCHIVE_OK != (ret = read_consume_bits(ar, rar, p, 5, &channels))) {
+ #ifdef __clang_analyzer__
+ /* Tell clang-analyzer that 'filt' does not leak.
+ add_new_filter passes off ownership. */
+ free(filt);
+ #endif
return ret;
+ }
filt->channels = channels + 1;
}
+ #ifdef __clang_analyzer__
+ /* Tell clang-analyzer that 'filt' does not leak.
+ add_new_filter passes off ownership. */
+ free(filt);
+ #endif
return ARCHIVE_OK;
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
index 3190b46..ebd33c5 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
@@ -50,6 +50,10 @@
#include <cm3p/zlib.h>
#endif
+#ifdef __clang_analyzer__
+#include <assert.h>
+#endif
+
#include "archive.h"
#include "archive_endian.h"
#include "archive_entry.h"
@@ -6626,6 +6630,11 @@ isoent_collect_dirs(struct vdd *vdd, struct isoent *rootent, int depth)
rootent = vdd->rootent;
np = rootent;
do {
+ #ifdef __clang_analyzer__
+ /* Tell clang-analyzer that pathtbl[depth] is in bounds. */
+ assert(depth < vdd->max_depth);
+ #endif
+
/* Register current directory to pathtable. */
path_table_add_entry(&(vdd->pathtbl[depth]), np);