Add linter warnings for missing ownership annotations#90
Add linter warnings for missing ownership annotations#90Ayushd785 wants to merge 6 commits intorizinorg:devfrom
Conversation
c8f7afe to
e5f82f0
Compare
src/lint.py
Outdated
|
|
||
| generic_types = {"RzList", "RzListIter", "RzPVector", "RzVector", "RzGraph"} | ||
|
|
||
| ownership_required_types = { |
There was a problem hiding this comment.
Like the change. But why only these types? Any pointer which is not const needs ownership info.
There was a problem hiding this comment.
Yaaa makes sense, this should apply to all non-const pointers. I'll update the logic to check if the return type is a non-const pointer instead of checking against specific type names. Will it be a good approach then?
There was a problem hiding this comment.
const merely means that the data structure and/or pointer is read-only ... the caller might still need to free the returned const pointer depending on whether the annotation is RZ_OWN or RZ_BORROW
There was a problem hiding this comment.
Hmm, so you're saying even const pointers need ownership annotations since const only affects mutability, not ownership?
But then, should we check ALL pointer returns, or still focus on specific types like container types (RzList, RzVector, etc.) that are heap-allocated?
There was a problem hiding this comment.
constmerely means that the data structure and/or pointer is read-only
i disagree. i expect any const pointer (returned) to be always borrowed
There was a problem hiding this comment.
i expect any const pointer (returned) to be always borrowed
That is a reasonable expectation and should be coded in the linter logic, meaning that there should be a warning when RZ_OWN is used with a returned const pointer.
Hmm, still need to check all pointer returns.
Anyway, I'm ok with checking all non-const pointer returns as a start. Hopefully there won't be a ton of warnings.
There was a problem hiding this comment.
Yes, lets do all non-const pointers. I assume the amount of changes would be significant. We can run linter manually first before merging, fix all occurences, and then merge the PR
There was a problem hiding this comment.
meaning that there should be a warning when RZ_OWN is used with a returned const pointer.
Good idea! Second this.
There was a problem hiding this comment.
Got it! So i have to check ALL non-const pointer returns for missing ownership annotations.
There was a problem hiding this comment.
I am sorry, everyone, for being inactive here. I am on a very tight schedule for the next 3-4 days. I will implement the suggested changes as soon as i get some time.
baa6b3f to
9262149
Compare
|
hi @notxvilka, I've added an extra check in This assumes anything in subprojects/ that doesn't start with "rz" is an Also fixed that minor typo. |
|
wait I have missed something. I need a logic which includes everything which has initials as 'rz' but does not have an underScore with it (eg. rz_util) i thought it was just rzheap edit - fixed |
1483b91 to
6919138
Compare
Screencast.From.2026-02-01.00-55-12.mp4 |
|
Ok, this is ready now. But before merging this, we need to fix those warnings in Rizin first, so that CI will not become instantly red. |
Okay Sure. |
Well, I was just wondering. what approach are you planning to use to fix |
Rot127
left a comment
There was a problem hiding this comment.
lgtm. But yeah, fixing all the warnings is needs some smart idea.
|
Created the issue to track this: rizinorg/rizin#5870 |
|
What about we add a file in our repo root which contains the modules to check? In the beginning it contains only modules which don't throw any warnings. Otherwise I don't see us making any progress? |
Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>
This would be a great approach! CI stays green while we make progress. In addition to this We could also add a script that auto-detects which modules are already clean (0 warnings) and suggests adding them to the whitelist. I'd be happy to implement this if it's useful! |

description
adds a linter warning for functions that return ownership-sensitive pointer types (
RzList,RzPVector,RzGraph) without an explicit ownership annotation.When a function returns one of these types as a pointer and is missing
RZ_OWNorRZ_BORROW, the linter now emits a warning indicating the function and location.ScreenShot

Fixes
#34