[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH for-4.9 2/2] oxenstored: make it work on FreeBSD



> On 18. Apr 2017, at 11:16, Ian Jackson <ian.jackson@xxxxxxxxxxxxx> wrote:
> 
> Wei Liu writes ("[PATCH for-4.9 2/2] oxenstored: make it work on FreeBSD"):
>> Call the uname syscall to determine sysname and return device names
>> accordingly.
> ...
>> -let xenstored_proc_kva = "/proc/xen/xsd_kva"
>> -let xenstored_proc_port = "/proc/xen/xsd_port"
>> +let xenstored_proc_kva =
>> +  let info = Unix_syscalls.uname () in
>> +  match info.sysname with
>> +  | "Linux" -> "/proc/xen/xsd_kva"
>> +  | "FreeBSD" -> "/dev/xen/xenstored"
>> +  | _ -> "nonexistent"
> 
> This isn't very good.  If this code wants to fail, it returns a string
> "nonexistent" which would then be used to construct pathnames, and
> actually accessed.
> 
> In Haskell one could simply leave the default case off, which would
> generate a runtime failure.  Is that possible in ocaml ?

In Ocaml you would either use “assert false” or raise a dedicated exception for 
the catch-all case. You would get a run-time Match_failure exception without 
but this is nasty. The current solution has the problem you describe.

— C 

 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.