The patch seems OK in general. On Sun, Jul 07, 2019 at 11:39:29PM +0200, Martin Kletzander wrote:
The way the code is generated is also not nice, I wish there was more code actually written in some files and not generated by the generator (as much hard-coded static strings as possible), maybe similarly to the states.c, I don't know.
Can you expand on what you mean by this?
Also up for discussion is whether the libnbd crate should be separate since the higher-level functionality it should provide will not be tightly coupled with libnbd itself and the releases (especially the numbers) do not need to happen in sync.
I also didn't understand what this means. It's a matter of personal preference but you can use multi-line string constants in OCaml which can be unlimited in length, so this:
+ pr "#[allow(unused_imports)]\n"; + pr "use std::os::raw::{c_char, c_int, c_uint, c_void};\n"; + pr "use std::os::unix::io::RawFd;\n"; + pr "use std::ffi::CStr;\n"; + pr "use libnbd_sys::*;\n"; + pr "use libc;\n"; + pr "\n"; (etc)
can be written as: pr "\ #[allow(unused_imports)] use std::os::raw::{c_char, c_int, c_uint, c_void}; use std::os::unix::io::RawFd; [...] "; These are still C-like printf-like strings so you still need to escape %, " and \. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW