Skip to contentSkip to conversation

blame: provide type of fingerprints pointer

PATCH In review René Scharfe 2 participants 2 messages Feb 23, 2020 – Feb 24, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blame: provide type of fingerprints pointer

The fingerprints member of struct blame_origin is a void pointer that is only ever used to reference objects of type struct fingerprint. Declare its type to allow the compiler to do type checks. We can keep its type opaque in blame.h, though -- only functions in blame.c need to know the actual definition of struct fingerprint.

---
 blame.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
blame.h +3 -1
index 4a9e1270b0..089b181ff2 100644
@@ -16,6 +16,8 @@
 #define BLAME_DEFAULT_MOVE_SCORE	20
 #define BLAME_DEFAULT_COPY_SCORE	40
 
+struct fingerprint;
+
 /*
  * One blob in a commit that is being suspected
  */
@@ -52,7 +54,7 @@ struct blame_origin {
 	struct blame_entry *suspects;
 	mmfile_t file;
 	int num_lines;
-	void *fingerprints;
+	struct fingerprint *fingerprints;
 	struct object_id blob_oid;
 	unsigned short mode;
 	/* guilty gets set when shipping any suspects to the final

--
2.25.1

Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · René Scharfe

The fingerprints member of struct blame_origin is a void pointer that is only ever used to reference objects of type struct fingerprint. Declare its type to allow the compiler to do type checks. We can keep its type opaque in blame.h, though -- only functions in blame.c need to know the actual definition of struct fingerprint.

Thanks.

Quoted 31 lines
---
  blame.h | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
blame.h +3 -2
index 4a9e1270b0..089b181ff2 100644
@@ -16,6 +16,8 @@
  #define BLAME_DEFAULT_MOVE_SCORE	20
  #define BLAME_DEFAULT_COPY_SCORE	40
 
+struct fingerprint;
+
  /*
   * One blob in a commit that is being suspected
   */
@@ -52,7 +54,7 @@ struct blame_origin {
  	struct blame_entry *suspects;
  	mmfile_t file;
  	int num_lines;
-	void *fingerprints;
+	struct fingerprint *fingerprints;
  	struct object_id blob_oid;
  	unsigned short mode;
  	/* guilty gets set when shipping any suspects to the final
--

2.25.1