Commit 4d8fe1cd by Patrick Steinhardt

coverity: model functions printing into git_buf

The `git_buf` structure seems to be too complicated to correctly
grasp for Coverity. As such, add simpler models trying to guide
Coverity and remove false positives related to these functions.
parent 956f1e23
...@@ -6,8 +6,11 @@ ...@@ -6,8 +6,11 @@
*/ */
void *realloc(void *ptr, size_t size); void *realloc(void *ptr, size_t size);
void *memmove(void *dest, const void *src, size_t n);
size_t strlen(const char *s); size_t strlen(const char *s);
typedef struct va_list_str *va_list;
typedef struct git_vector { typedef struct git_vector {
void **contents; void **contents;
size_t length; size_t length;
...@@ -35,3 +38,38 @@ int git_buf_len(const struct git_buf *buf) ...@@ -35,3 +38,38 @@ int git_buf_len(const struct git_buf *buf)
{ {
return strlen(buf->ptr); return strlen(buf->ptr);
} }
int git_buf_vprintf(git_buf *buf, const char *format, va_list ap)
{
char ch, *s;
size_t len;
__coverity_string_null_sink__(format);
__coverity_string_size_sink__(format);
ch = *format;
ch = *(char *)ap;
buf->ptr = __coverity_alloc__(len);
__coverity_writeall__(buf->ptr);
buf->size = len;
return 0;
}
int git_buf_put(git_buf *buf, const char *data, size_t len)
{
buf->ptr = __coverity_alloc__(buf->size + len + 1);
memmove(buf->ptr + buf->size, data, len);
buf->size += len;
buf->ptr[buf->size + len] = 0;
return 0;
}
int git_buf_set(git_buf *buf, const void *data, size_t len)
{
buf->ptr = __coverity_alloc__(len + 1);
memmove(buf->ptr, data, len);
buf->size = len + 1;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment