From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH 3/6] coverity-model: remove model for more allocation functions
Date: Sat, 31 Jul 2021 08:27:38 +0200 [thread overview]
Message-ID: <20210731062741.301102-4-pbonzini@redhat.com> (raw)
In-Reply-To: <20210731062741.301102-1-pbonzini@redhat.com>
These models are not needed anymore now that Coverity does not check
anymore that the result is used with "g_free". Coverity understands
GCC attributes and uses them to detect leaks.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/coverity-scan/model.c | 105 +---------------------------------
1 file changed, 1 insertion(+), 104 deletions(-)
diff --git a/scripts/coverity-scan/model.c b/scripts/coverity-scan/model.c
index 8e64a84c5a..1a5f39d2ae 100644
--- a/scripts/coverity-scan/model.c
+++ b/scripts/coverity-scan/model.c
@@ -263,7 +263,7 @@ void *g_try_realloc_n(void *ptr, size_t nmemb, size_t size)
return g_realloc_n(ptr, nmemb, size);
}
-/* Trivially derive the g_FOO() from the g_FOO_n() */
+/* Derive the g_FOO() from the g_FOO_n() */
void *g_malloc(size_t size)
{
@@ -295,109 +295,6 @@ void *g_try_realloc(void *ptr, size_t size)
return g_try_realloc_n(ptr, 1, size);
}
-/* Other memory allocation functions */
-
-void *g_memdup(const void *ptr, unsigned size)
-{
- unsigned char *dup;
- unsigned i;
-
- if (!ptr) {
- return NULL;
- }
-
- dup = g_malloc(size);
- for (i = 0; i < size; i++)
- dup[i] = ((unsigned char *)ptr)[i];
- return dup;
-}
-
-/*
- * GLib string allocation functions
- */
-
-char *g_strdup(const char *s)
-{
- char *dup;
- size_t i;
-
- if (!s) {
- return NULL;
- }
-
- __coverity_string_null_sink__(s);
- __coverity_string_size_sink__(s);
- dup = __coverity_alloc_nosize__();
- __coverity_mark_as_afm_allocated__(dup, AFM_free);
- for (i = 0; (dup[i] = s[i]); i++) ;
- return dup;
-}
-
-char *g_strndup(const char *s, size_t n)
-{
- char *dup;
- size_t i;
-
- __coverity_negative_sink__(n);
-
- if (!s) {
- return NULL;
- }
-
- dup = g_malloc(n + 1);
- for (i = 0; i < n && (dup[i] = s[i]); i++) ;
- dup[i] = 0;
- return dup;
-}
-
-char *g_strdup_printf(const char *format, ...)
-{
- char ch, *s;
- size_t len;
-
- __coverity_string_null_sink__(format);
- __coverity_string_size_sink__(format);
-
- ch = *format;
-
- s = __coverity_alloc_nosize__();
- __coverity_writeall__(s);
- __coverity_mark_as_afm_allocated__(s, AFM_free);
- return s;
-}
-
-char *g_strdup_vprintf(const char *format, va_list ap)
-{
- char ch, *s;
- size_t len;
-
- __coverity_string_null_sink__(format);
- __coverity_string_size_sink__(format);
-
- ch = *format;
-
- s = __coverity_alloc_nosize__();
- __coverity_writeall__(s);
- __coverity_mark_as_afm_allocated__(s, AFM_free);
-
- return len;
-}
-
-char *g_strconcat(const char *s, ...)
-{
- char *s;
-
- /*
- * Can't model: last argument must be null, the others
- * null-terminated strings
- */
-
- s = __coverity_alloc_nosize__();
- __coverity_writeall__(s);
- __coverity_mark_as_afm_allocated__(s, AFM_free);
- return s;
-}
-
/* Other glib functions */
typedef struct pollfd GPollFD;
--
2.31.1
next prev parent reply other threads:[~2021-07-31 6:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-31 6:27 [PATCH 0/6] Updates for Coverity modeling file Paolo Bonzini
2021-07-31 6:27 ` [PATCH 1/6] coverity-model: update address_space_read/write models Paolo Bonzini
2021-08-02 12:31 ` Peter Maydell
2021-07-31 6:27 ` [PATCH 2/6] coverity-model: make g_free a synonym of free Paolo Bonzini
2021-08-02 12:32 ` Peter Maydell
2021-07-31 6:27 ` Paolo Bonzini [this message]
2021-08-02 12:34 ` [PATCH 3/6] coverity-model: remove model for more allocation functions Peter Maydell
2021-07-31 6:27 ` [PATCH 4/6] coverity-model: clean up the models for array " Paolo Bonzini
2021-08-02 12:36 ` Peter Maydell
2021-08-02 16:20 ` Paolo Bonzini
2021-08-04 8:35 ` Markus Armbruster
2021-08-04 8:43 ` Peter Maydell
2021-07-31 6:27 ` [PATCH 5/6] coverity-model: constrain g_malloc/g_malloc0/g_realloc as never returning NULL Paolo Bonzini
2021-08-02 12:37 ` Peter Maydell
2021-07-31 6:27 ` [PATCH 6/6] coverity-model: write models fully for non-array allocation functions Paolo Bonzini
2021-08-02 12:38 ` Peter Maydell
2021-08-02 12:46 ` [PATCH 0/6] Updates for Coverity modeling file Peter Maydell
2021-08-02 16:22 ` Paolo Bonzini
2021-08-03 6:04 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210731062741.301102-4-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).