
On Fri, Apr 25, 2014 at 12:51:54AM +0530, Nehal J Wani wrote:
+ * virFileFindResourceFull: + * @filename: libvirt distributed filename without any path + * @prefix: optional string to prepend to filename + * @suffix: optional string to append to filename + * @builddir: location of the binary in the source tree build tree + * @installdir: location of the installed binary + * @envname: environment variable used to override all dirs + * + * A helper which will return a path to @filename within + * the current build tree, if the calling binary is being + * run from the source tree. Otherwise it will return the + * path in the installed location. + * + * If @envname is none-NULL it will override all other + * directory lookup + * + * Only use this with @filename files that are part of + * the libvirt tree, not 3rd party binaries/files. + */
Shouldn't we be mentioning here that its caller's responsibility to free the returned value?
Yes, though any time 'char *' is returned the caller is expected to free the result. If the function owns the pointer it should always use 'const char *' instead.
I really liked the generalization. I have gone through each patch of this series and have only one question. The recursive grep: grep "main(int argc" -r ./* in libvirt's root directory, gives the following files: ./daemon/libvirtd.c ./examples/domsuspend/suspend.c ./examples/hellolibvirt/hellolibvirt.c ./examples/openauth/openauth.c ./examples/object-events/event-test.c ./src/lxc/lxc_controller.c ./src/security/virt-aa-helper.c ./src/locking/lock_daemon.c ./src/locking/sanlock_helper.c ./src/util/iohelper.c ./src/storage/parthelper.c ./tests/test_conf.c ./tests/testutils.h ./tests/testutils.h ./tests/commandhelper.c ./tests/shunloadtest.c ./tests/ssh.c ./tests/seclabeltest.c ./tools/virt-host-validate.c ./tools/virt-login-shell.c ./tools/virsh.c Shouldn't we be calling virFileActivateDirOverride(argv[0]) in all of them?
The examples need to stick to public libvirt APIs only. With the exception of probably virsh.c none of the others should need to load resources. So I think virsh is the only important one here - since it can autospawn libvirtd, so I'll look at making that work. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|