Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi.new_handle(None) #4

Closed
avg-I opened this issue Mar 20, 2015 · 1 comment
Closed

ffi.new_handle(None) #4

avg-I opened this issue Mar 20, 2015 · 1 comment

Comments

@avg-I
Copy link

avg-I commented Mar 20, 2015

I see the following code

config = libzfs.zpool_get_config(self.hdl, ffi.new_handle(None))

here https://github.com/Xaroth/libzfs-python/blob/master/libzfs/zpool.py#L133

As far as I can see from the CFFI documentation ffi.new_handle(None) produces a cdata object representing a void* pointer and that pointer is associated with None. Not sure if that makes sense at all to associate with None. But what worries me more is that the produced void* pointer is passed as the second argument to zpool_get_config() which actually interprets it as a pointer to a pointer, nvlist_t** and assigns a value to that pointer. I am not sure if it is safe to do that via a pointer returned from ffi.new_handle(). My impression is that such a pointer is never meant to be dereferenced. I think that it can only passed between python and C code and used with ffi.from_handle().

Perhaps ffi.NULL would be better to use here?

@Xaroth
Copy link
Owner

Xaroth commented Mar 21, 2015

Hm,

I'm actually not sure anymore why I did new_handle.. but I did some checks and ffi.NULL seems to work fine (and actually sounds more logical). I've also changed it in .list, where the same would apply (there the handle is passed to the iter callback).

Changed, fixed, pushed.

@Xaroth Xaroth closed this as completed Mar 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants