Skip to contentSkip to conversation

coverity: Store the modelling file in the source tree.

PATCH Superseded Andrew Cooper 5 participants 18 messages Jan 23, 2014 – Jan 24, 2014

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 coverity: Store the modelling file in the source tree.

CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as part of the 4.4 release.

---
 misc/coverity_model.c |   98 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 misc/coverity_model.c
misc/coverity_model.c new file +98 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ *   available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs
+ *   and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ *   variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.
+ *
+ * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ * 2011, 2012, 2013 Python Software Foundation; All Rights Reserved
+ *
+ * The Xen Coverity Scan modelling file used the cpython modelling file as a
+ * reference to get started (suggested by Coverty Scan themselves as a good
+ * example), but all content is Xen specific.
+ */
+
+/*
+ * Useful references:
+ *   https://scan.coverity.com/models
+ */
+
+/* Definitions */
+#define NULL (void *)0
+#define PAGE_SIZE 4096UL
+#define PAGE_MASK (~(PAGE_SIZE-1))
+
+#define assert(cond) /* empty */
+
+struct page_info {};
+
+/*
+ * Xen malloc.  Behaves exactly like regular malloc(), except it also contains
+ * an alignment parameter.
+ *
+ * TODO: work out how to correctly model bad alignments as errors.
+ */
+void *_xmalloc(unsigned long size, unsigned long align)
+{
+    int has_memory;
+
+    __coverity_negative_sink__(size);
+    __coverity_negative_sink__(align);
+
+    if ( has_memory )
+        return __coverity_alloc__(size);
+    else
+        return NULL;
+}
+
+/*
+ * Xen free.  Frees a pointer allocated by _xmalloc().
+ */
+void xfree(void *va)
+{
+    __coverity_free__(va);
+}
+
+
+/*
+ * map_domain_page() takes an existing domain page and possibly maps it into
+ * the Xen pagetables, to allow for direct access.  Model this as a memory
+ * allocation of exactly 1 page.
+ *
+ * map_domain_page() never fails. (It will BUG() before returning NULL)
+ *
+ * TODO: work out how to correctly model the behaviour that this function will
+ * only ever return page aligned pointers.
+ */
+void *map_domain_page(unsigned long mfn)
+{
+    return __coverity_alloc__(PAGE_SIZE);
+}
+
+/*
+ * unmap_domain_page() will unmap a page.  Model it as a free().
+ */
+void unmap_domain_page(const void *va)
+{
+    __coverity_free__(va);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
1.7.10.4
#1 lore raw

Andrew Cooper writes ("[Xen-devel] [PATCH v5] coverity: Store the modelling file in the source tree."):

Quoted 7 lines
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

This is fine as far as it goes. But surely we should also include some build instructions.

Ian.

#2 lore raw
Quoted 8 lines · Ian Jackson

Andrew Cooper writes ("[Xen-devel] [PATCH v5] coverity: Store the modelling file in the source tree."):

Quoted 7 lines
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>
Quoted 4 lines

This is fine as far as it goes. But surely we should also include some build instructions.

Ian.

There arn't really build instruction. The way to use it with coverity scan is for one of the coverity scan admins to click the "Upload a new modelling file" button. Any scan initiated will use the latest modelling file.

~Andrew

#3 lore raw
In reply to Andrew Cooper
Quoted 29 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as part of the 4.4 release.

---
  misc/coverity_model.c |   98 +++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 98 insertions(+)

create mode 100644 misc/coverity_model.c

misc/coverity_model.c new file +5 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to avoid false
+ * positives.
+ *

misc/coverity_model.c line 15

Quoted 10 lines
misc/coverity_model.c new file +10 -0
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ *   available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs
+ *   and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ *   variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.

So this file isn't compiled; it's manually uploaded as part of the coverity scanning process; and could be provided out-of-band, but it's just convenient to put it in the tree, particularly if any of these things should change as things go forward. (Hence comparing it to documentation.) Is that right?

-George

#4 lore raw
Quoted 54 lines · George Dunlap
Quoted 38 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as
part of
the 4.4 release.

---
  misc/coverity_model.c |   98
+++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 98 insertions(+)

create mode 100644 misc/coverity_model.c

misc/coverity_model.c new file +3 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to

avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ * available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs

Quoted 8 lines

+ * and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ * variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.

So this file isn't compiled; it's manually uploaded as part of the coverity scanning process; and could be provided out-of-band, but it's just convenient to put it in the tree, particularly if any of these things should change as things go forward. (Hence comparing it to documentation.) Is that right?

Quoted 2 lines

-George

Correct. I believe internally Coverity compiles it (at least to an AST), but that is completely opaque to users of Scan.

~Andrew

#5 lore raw
Quoted 54 lines · Andrew Cooper
Quoted 53 lines · George Dunlap
Quoted 38 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as
part of
the 4.4 release.

---
   misc/coverity_model.c |   98
+++++++++++++++++++++++++++++++++++++++++++++++++
   1 file changed, 98 insertions(+)

create mode 100644 misc/coverity_model.c

misc/coverity_model.c new file +3 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to

avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ * available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs

Quoted 8 lines

+ * and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ * variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.

So this file isn't compiled; it's manually uploaded as part of the coverity scanning process; and could be provided out-of-band, but it's just convenient to put it in the tree, particularly if any of these things should change as things go forward. (Hence comparing it to documentation.) Is that right?

Quoted 4 lines
Quoted 2 lines

-George

Correct. I believe internally Coverity compiles it (at least to an AST), but that is completely opaque to users of Scan.

Right; I have a hard time coming up with a compelling reason to wait for this one.

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it ".txt", and include some instructions at the top with a line that says "---- cut here 8< ---" or something?

-George

#6 lore raw
Quoted 63 lines · George Dunlap
Quoted 54 lines · Andrew Cooper
Quoted 53 lines · George Dunlap
Quoted 38 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as
part of
the 4.4 release.

---
   misc/coverity_model.c |   98
+++++++++++++++++++++++++++++++++++++++++++++++++
   1 file changed, 98 insertions(+)

create mode 100644 misc/coverity_model.c

misc/coverity_model.c new file +3 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to

avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ * available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs

Quoted 8 lines

+ * and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ * variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.

So this file isn't compiled; it's manually uploaded as part of the coverity scanning process; and could be provided out-of-band, but it's just convenient to put it in the tree, particularly if any of these things should change as things go forward. (Hence comparing it to documentation.) Is that right?

Quoted 4 lines
Quoted 2 lines

-George

Correct. I believe internally Coverity compiles it (at least to an AST), but that is completely opaque to users of Scan.

Right; I have a hard time coming up with a compelling reason to wait for this one.

Quoted 8 lines

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it ".txt", and include some instructions at the top with a line that says "---- cut here 8< ---" or something?

-George

Not really - Coverity uses the file extension to work out how to interpret the modelling file. ".c" is correct here, and will cause smart text editors to apply proper syntax highlighting.

Alternates are .cpp and .java, depending on the primary language of the project.

~Andrew

#7 lore raw
Quoted 70 lines · Andrew Cooper
Quoted 69 lines · George Dunlap
Quoted 54 lines · Andrew Cooper
Quoted 53 lines · George Dunlap
Quoted 38 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as
part of
the 4.4 release.

---
    misc/coverity_model.c |   98
+++++++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 98 insertions(+)

create mode 100644 misc/coverity_model.c

misc/coverity_model.c new file +3 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to

avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ * available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs

Quoted 8 lines

+ * and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ * variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.

So this file isn't compiled; it's manually uploaded as part of the coverity scanning process; and could be provided out-of-band, but it's just convenient to put it in the tree, particularly if any of these things should change as things go forward. (Hence comparing it to documentation.) Is that right?

Quoted 4 lines
Quoted 2 lines

-George

Correct. I believe internally Coverity compiles it (at least to an AST), but that is completely opaque to users of Scan.

Right; I have a hard time coming up with a compelling reason to wait for this one.

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it ".txt", and include some instructions at the top with a line that says "---- cut here 8< ---" or something?

Quoted 7 lines
Quoted 1 line

-George

Not really - Coverity uses the file extension to work out how to interpret the modelling file. ".c" is correct here, and will cause smart text editors to apply proper syntax highlighting.

Alternates are .cpp and .java, depending on the primary language of the project.

Yes, I assumed that *coverity* needs it to be a .c. But it doesn't need to be a .c file in the xen tree -- the instructions could say, "Place the text below into a file named coverity_model.c".

-George

#8 lore raw
Quoted 76 lines · George Dunlap
Quoted 75 lines · Andrew Cooper
Quoted 62 lines · George Dunlap
Quoted 54 lines · Andrew Cooper
Quoted 53 lines · George Dunlap
Quoted 38 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as
part of
the 4.4 release.

---
    misc/coverity_model.c |   98
+++++++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 98 insertions(+)

create mode 100644 misc/coverity_model.c

misc/coverity_model.c new file +3 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to

avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ * available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs

Quoted 8 lines

+ * and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ * variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.

So this file isn't compiled; it's manually uploaded as part of the coverity scanning process; and could be provided out-of-band, but it's just convenient to put it in the tree, particularly if any of these things should change as things go forward. (Hence comparing it to documentation.) Is that right?

Quoted 4 lines
Quoted 2 lines

-George

Correct. I believe internally Coverity compiles it (at least to an AST), but that is completely opaque to users of Scan.

Right; I have a hard time coming up with a compelling reason to wait for this one.

Quoted 8 lines

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it ".txt", and include some instructions at the top with a line that says "---- cut here 8< ---" or something?

-George

Not really - Coverity uses the file extension to work out how to interpret the modelling file. ".c" is correct here, and will cause smart text editors to apply proper syntax highlighting.

Quoted 6 lines
Quoted 2 lines

Alternates are .cpp and .java, depending on the primary language of the project.

Yes, I assumed that *coverity* needs it to be a .c. But it doesn't need to be a .c file in the xen tree -- the instructions could say, "Place the text below into a file named coverity_model.c".

This file is uploaded via a web interface. It'd be far more convenient to browse with the browesers file dialog to the exact file in the xen source tree.

Perhaps a README next to the file? Perhaps
misc/coverity/{README,model.c} ?

Ian.

#9 lore raw
In reply to George Dunlap
Quoted 79 lines · George Dunlap
Quoted 78 lines · Andrew Cooper
Quoted 65 lines · George Dunlap
Quoted 57 lines · Andrew Cooper
Quoted 56 lines · George Dunlap
Quoted 40 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include
it as
part of
the 4.4 release.

---
    misc/coverity_model.c |   98
+++++++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 98 insertions(+)

create mode 100644 misc/coverity_model.c

misc/coverity_model.c new file +3 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to

avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void
are
+ * available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs

Quoted 8 lines

+ * and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ * variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.

So this file isn't compiled; it's manually uploaded as part of the coverity scanning process; and could be provided out-of-band, but it's
just convenient to put it in the tree, particularly if any of these things should change as things go forward. (Hence comparing it to documentation.) Is that right?

Quoted 4 lines
Quoted 2 lines

-George

Correct. I believe internally Coverity compiles it (at least to an AST), but that is completely opaque to users of Scan.

Right; I have a hard time coming up with a compelling reason to wait for this one.

Quoted 8 lines

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it ".txt", and include some instructions at the top with a line that says "---- cut here 8< ---" or something?

-George

Not really - Coverity uses the file extension to work out how to interpret the modelling file. ".c" is correct here, and will cause smart text editors to apply proper syntax highlighting.

Quoted 8 lines
Quoted 2 lines

Alternates are .cpp and .java, depending on the primary language of the project.

Yes, I assumed that *coverity* needs it to be a .c. But it doesn't need to be a .c file in the xen tree -- the instructions could say, "Place the text below into a file named coverity_model.c".

-George

This file was deliberately placed in a brand new directory, away from any Makefiles which might try to compile it for this reason.

Requiring users to post-process this file just to help prevent someone from accidentally trying to compile it seems crazy IMO. The worst that happens is that someone tries to compile it and it fails to compile.

~Andrew

#10 lore raw
Quoted 86 lines · Andrew Cooper
Quoted 85 lines · George Dunlap
Quoted 73 lines · Andrew Cooper
Quoted 72 lines · George Dunlap
Quoted 57 lines · Andrew Cooper
Quoted 56 lines · George Dunlap
Quoted 40 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include
it as
part of
the 4.4 release.

---
     misc/coverity_model.c |   98
+++++++++++++++++++++++++++++++++++++++++++++++++
     1 file changed, 98 insertions(+)

create mode 100644 misc/coverity_model.c

misc/coverity_model.c new file +3 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to

avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void
are
+ * available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs

Quoted 8 lines

+ * and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ * variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.

So this file isn't compiled; it's manually uploaded as part of the coverity scanning process; and could be provided out-of-band, but it's
just convenient to put it in the tree, particularly if any of these things should change as things go forward. (Hence comparing it to documentation.) Is that right?

Quoted 4 lines
Quoted 2 lines

-George

Correct. I believe internally Coverity compiles it (at least to an AST), but that is completely opaque to users of Scan.

Right; I have a hard time coming up with a compelling reason to wait for this one.

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it ".txt", and include some instructions at the top with a line that says "---- cut here 8< ---" or something?

Quoted 7 lines
Quoted 1 line

-George

Not really - Coverity uses the file extension to work out how to interpret the modelling file. ".c" is correct here, and will cause smart text editors to apply proper syntax highlighting.

Alternates are .cpp and .java, depending on the primary language of the project.

Yes, I assumed that *coverity* needs it to be a .c. But it doesn't need to be a .c file in the xen tree -- the instructions could say, "Place the text below into a file named coverity_model.c".

Quoted 7 lines
Quoted 1 line

-George

This file was deliberately placed in a brand new directory, away from any Makefiles which might try to compile it for this reason.

Requiring users to post-process this file just to help prevent someone from accidentally trying to compile it seems crazy IMO. The worst that happens is that someone tries to compile it and it fails to compile.

Right, well a directory named "misc" probably won't remain empty for long. :-) I'd prefer Ian's suggestion of misc/coverity/, or maybe just coverity/; but I'm not too particular about it.

(And the consensus seems to be that .c shoud be fine, so I'll go along with that too.)

-George

#11 lore raw
Quoted 99 lines · George Dunlap
Quoted 90 lines · Andrew Cooper
Quoted 89 lines · George Dunlap
Quoted 76 lines · Andrew Cooper
Quoted 75 lines · George Dunlap
Quoted 58 lines · Andrew Cooper
Quoted 57 lines · George Dunlap
Quoted 41 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include
it as
part of
the 4.4 release.

---
     misc/coverity_model.c |   98
+++++++++++++++++++++++++++++++++++++++++++++++++
     1 file changed, 98 insertions(+)

create mode 100644 misc/coverity_model.c

misc/coverity_model.c new file +3 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to

avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void
are
+ * available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary
structs

Quoted 8 lines

+ * and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ * variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.

So this file isn't compiled; it's manually uploaded as part of the coverity scanning process; and could be provided out-of-band, but it's
just convenient to put it in the tree, particularly if any of these things should change as things go forward. (Hence comparing it to documentation.) Is that right?

Quoted 4 lines
Quoted 2 lines

-George

Correct. I believe internally Coverity compiles it (at least to an AST), but that is completely opaque to users of Scan.

Right; I have a hard time coming up with a compelling reason to wait for this one.

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it
".txt", and include some instructions at the top with a line that says
"---- cut here 8< ---" or something?

Quoted 8 lines
Quoted 1 line

-George

Not really - Coverity uses the file extension to work out how to interpret the modelling file. ".c" is correct here, and will cause smart text editors to apply proper syntax highlighting.

Alternates are .cpp and .java, depending on the primary language of the
project.

Yes, I assumed that *coverity* needs it to be a .c. But it doesn't need to be a .c file in the xen tree -- the instructions could say, "Place the text below into a file named coverity_model.c".

Quoted 7 lines
Quoted 1 line

-George

This file was deliberately placed in a brand new directory, away from any Makefiles which might try to compile it for this reason.

Requiring users to post-process this file just to help prevent someone from accidentally trying to compile it seems crazy IMO. The worst that happens is that someone tries to compile it and it fails to compile.

Quoted 9 lines

Right, well a directory named "misc" probably won't remain empty for long. :-) I'd prefer Ian's suggestion of misc/coverity/, or maybe just coverity/; but I'm not too particular about it.

(And the consensus seems to be that .c shoud be fine, so I'll go along with that too.)

-George

I will send v6 moving it to misc/coverity/, and the result of the copyright thread

~Andrew

#12 lore raw
In reply to George Dunlap
Quoted 12 lines · George Dunlap
Quoted 11 lines · Andrew Cooper
Quoted 6 lines · George Dunlap

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it ".txt", and include some instructions at the top with a line that says "---- cut here 8< ---" or something?

-George

Not really - Coverity uses the file extension to work out how to interpret the modelling file. ".c" is correct here, and will cause smart text editors to apply proper syntax highlighting.

Quoted 6 lines
Quoted 2 lines

Alternates are .cpp and .java, depending on the primary language of the project.

Yes, I assumed that *coverity* needs it to be a .c. But it doesn't need to be a .c file in the xen tree -- the instructions could say, "Place the text below into a file named coverity_model.c".

+1. I don't think it's confusing for humans but we don't want e.g. ctags/cscope or IDEs picking up the coverity versions of things.

Tim.

#13 lore raw
Quoted 16 lines · Tim Deegan
Quoted 15 lines · George Dunlap
Quoted 13 lines · Andrew Cooper
Quoted 6 lines · George Dunlap

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it ".txt", and include some instructions at the top with a line that says "---- cut here 8< ---" or something?

-George

Not really - Coverity uses the file extension to work out how to interpret the modelling file. ".c" is correct here, and will cause smart text editors to apply proper syntax highlighting.

Alternates are .cpp and .java, depending on the primary language of the project.

Quoted 7 lines
Quoted 3 lines

Yes, I assumed that *coverity* needs it to be a .c. But it doesn't need to be a .c file in the xen tree -- the instructions could say, "Place the text below into a file named coverity_model.c".

+1. I don't think it's confusing for humans but we don't want e.g. ctags/cscope or IDEs picking up the coverity versions of things.

Do you run tags on the whole of xen.git? I run it individually on the xen and tools subdirs, because all the other cruft in the tree is just too noisy otherwise.

Ian.

#14 lore raw
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Tim Deegan
Quoted 18 lines · George Dunlap
Quoted 6 lines · Andrew Cooper
Quoted 5 lines · George Dunlap

The name of the file might be a bit confusing though, if people think it is supposed to be compliled... would it make sense maybe to call it ".txt", and include some instructions at the top with a line that says "---- cut here 8< ---" or something?

Quoted 7 lines
Quoted 1 line

-George

Not really - Coverity uses the file extension to work out how to interpret the modelling file. ".c" is correct here, and will cause smart text editors to apply proper syntax highlighting.

Alternates are .cpp and .java, depending on the primary language of the project.

Yes, I assumed that *coverity* needs it to be a .c. But it doesn't need to be a .c file in the xen tree -- the instructions could say, "Place the text below into a file named coverity_model.c".

Quoted 5 lines
Quoted 3 lines

+1. I don't think it's confusing for humans but we don't want e.g. ctags/cscope or IDEs picking up the coverity versions of things.

Do you run tags on the whole of xen.git?

Not usually; I guess it's no worse than the multiple architectures, minios &c where it is. So, stet as a .c.

Tim.

#15 lore raw
In reply to Andrew Cooper
Quoted 36 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as part of the 4.4 release.

---
 misc/coverity_model.c |   98 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 misc/coverity_model.c
misc/coverity_model.c new file +12 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ *   available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs
+ *   and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ *   variable could be either NULL or have some data.

misc/coverity_model.c line 22

Quoted 10 lines
misc/coverity_model.c new file +10 -0
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.
+ *
+ * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ * 2011, 2012, 2013 Python Software Foundation; All Rights Reserved
+ *
+ * The Xen Coverity Scan modelling file used the cpython modelling file as a
+ * reference to get started (suggested by Coverty Scan themselves as a good
+ * example), but all content is Xen specific.

Given that you (I pressume?) wrote at least some of the C like stuff I think you can include your copyright too as well as the Python one. Is there actually any cpython stuff left?

If there were a link to the docs in this comment that would be good too.

#16 lore raw
Quoted 51 lines · Ian Campbell
Quoted 36 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as part of the 4.4 release.

---
 misc/coverity_model.c |   98 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 misc/coverity_model.c
misc/coverity_model.c new file +12 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
+ * This is a modelling file for Coverity Scan. Modelling helps to avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ *   available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs
+ *   and similar types are sufficient.
+ * - An uninitialized local pointer is not an error. It signifies that the
+ *   variable could be either NULL or have some data.

misc/coverity_model.c line 22

Quoted 10 lines
misc/coverity_model.c new file +10 -0
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.
+ *
+ * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ * 2011, 2012, 2013 Python Software Foundation; All Rights Reserved
+ *
+ * The Xen Coverity Scan modelling file used the cpython modelling file as a
+ * reference to get started (suggested by Coverty Scan themselves as a good
+ * example), but all content is Xen specific.

Given that you (I pressume?) wrote at least some of the C like stuff I think you can include your copyright too as well as the Python one. Is there actually any cpython stuff left?

Quoted 3 lines

If there were a link to the docs in this comment that would be good too.

See "Useful links" in the comment below this one in the file.

Most of this comment is from the cpython file, and I suppose technically the "#define NULL (void)0" and "#define assert() /*empty*/" were.

But mainly, the cpython was just an example of an existing modelling file, which was a substantially more useful when working out how to write the Xen one than the Coverity documentation of which each of the __coverity_$FOO() functions mean and do.

~Andrew

#17 lore raw
Quoted 20 lines · Andrew Cooper
Quoted 19 lines · Ian Campbell
Quoted 18 lines · Andrew Cooper
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC George Dunlap <[email protected]>

---

George:
This is just documentation, and it would be nice to include it as part of the 4.4 release.

---
 misc/coverity_model.c |   98 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 misc/coverity_model.c
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
misc/coverity_model.c new file +2 -0
new file mode 100644
index 0000000..418d25e
@@ -0,0 +1,98 @@
+/* Coverity Scan model
+ *
Quoted 8 lines

misc/coverity_model.c line 10

Quoted 8 lines
misc/coverity_model.c new file +8 -0
+ * This is a modelling file for Coverity Scan. Modelling helps to avoid false
+ * positives.
+ *
+ * - A model file can't import any header files.
+ * - Therefore only some built-in primitives like int, char and void are
+ *   available but not NULL etc.
+ * - Mode-ling doesn't need full structs and typedefs. Rudimentary structs
+ *   and similar types are sufficient.

Is "Mode-ling" a word?

Quoted 16 lines
Quoted 16 lines

misc/coverity_model.c line 22

Quoted 12 lines
misc/coverity_model.c new file +12 -0
+ * - An uninitialized local pointer is not an error. It signifies that the
+ *   variable could be either NULL or have some data.
+ *
+ * Coverity Scan doesn't pick up modifications automatically. The model file
+ * must be uploaded by an admin in the analysis.
+ *
+ * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ * 2011, 2012, 2013 Python Software Foundation; All Rights Reserved
+ *
+ * The Xen Coverity Scan modelling file used the cpython modelling file as a
+ * reference to get started (suggested by Coverty Scan themselves as a good
+ * example), but all content is Xen specific.

Given that you (I pressume?) wrote at least some of the C like stuff I think you can include your copyright too as well as the Python one. Is there actually any cpython stuff left?

Quoted 5 lines
Quoted 3 lines

If there were a link to the docs in this comment that would be good too.

See "Useful links" in the comment below this one in the file.

Oops, stopped after the first comment ;-)

Quoted 7 lines

Most of this comment is from the cpython file, and I suppose technically the "#define NULL (void)0" and "#define assert() /*empty*/" were.

But mainly, the cpython was just an example of an existing modelling file, which was a substantially more useful when working out how to write the Xen one than the Coverity documentation of which each of the __coverity_$FOO() functions mean and do.

Might be worth including a link to the python one?
I'd normally do the copyright as:
Write Copyright (c) 2013-2014 Andrew Cooper (or Citrix etc as you wish/are required)

Based on <http://linky> which is:
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Python Software Foundation; All Rights
Reserved

Ian.