mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 14:19:59 -05:00
libarchive: Suppress clang-analyzer warnings
This commit is contained in:
@@ -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))) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user