Skip to content

Conversation

@robhoes
Copy link
Member

@robhoes robhoes commented May 19, 2016

Some sysfs files are "empty", for a good reason.

Signed-off-by: Rob Hoes rob.hoes@citrix.com

Some sysfs files are "empty", for a good reason.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
with exn -> close_in inchan; raise (Read_error file)
with
| End_of_file -> close_in inchan; ""
| exn -> error "%s" (Printexc.to_string exn); close_in inchan; raise (Read_error file)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK, but might be neater as

let read_one_line file =
  let inchan = open_in file in
  try
    finally
      (fun () -> input_line inchan)
      (fun () -> close_in inchan)
  with
    | End_of_file -> ""
    | exn -> error "%s" (Printexc.to_string exn); raise (Read_error file)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The open_in could also fail. So it could also go inside the try and the error could be handled in the with block.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All agreed; will update.

@robhoes
Copy link
Member Author

robhoes commented May 19, 2016

@johnelse I've added a fixup. Will squash it before merging.

@johnelse
Copy link
Collaborator

Looks good!

@robhoes robhoes merged commit 0cc3054 into xapi-project:master May 19, 2016
@robhoes robhoes deleted the ca211448 branch May 19, 2016 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants