gsegt / yagolic

0 stars 0 forks source link

:lock: Add null checks on every function and system calls #22

Closed gsegt closed 9 months ago

gsegt commented 10 months ago

I feel like I over did this one a bit XD

kaoliiny commented 10 months ago

What a heck is going on this MR?!

kaoliiny commented 10 months ago

I mean this is not the way it should be done. Later l could provide an example

gsegt commented 10 months ago

For some reason, I expected that outcome. I'll have another go at it. Are you interested in the thought process of how this solution came to be?

gsegt commented 10 months ago

So, I wanted to add checks on every system calls and every function that use a pointer. I wanted to have a common error code and more explicit message than a basic "Passed a NULL pointer", hence the code to store them. I did not want to use defines as my understanding was that it is recommended to use constants instead, so I used some. Plus, it put the structure to have more in the future. Finally, I made a function to not repeat myself with the checks. This is how the code of this PR came to be. Now, I am open to suggestions on how to improve it and have another go at it.

gsegt commented 10 months ago

I had another go at it with assert and a MACRO. I thought that having a function would be a bit cleaner, even with the macro. Let me know what you think.

gsegt commented 9 months ago

Can you tell me why? I really don't get what is wrong with this second implementation.

kaoliiny commented 9 months ago

This is an outdated comment l made a concilium to actually get the point way this solution is actually right. Can be merged

gsegt commented 9 months ago

This PR has been rebased on main, I'll let you have another look since quite a bit changed since the solution you approved was made.