> > > On 2 Jul 2018, at 09:43, Frediano Ziglio <fziglio@xxxxxxxxxx> wrote: > > > > Do not assume we allocated the handle doing the cleanup. > > Comment seems misleading: CloseHandle seems to accept INVALID_HANDLE_VALUE as > input, although the MS documentation is not entirely clear. > I think both NULL and INVALID_HANDLE_VALUE are invalid values. Documentation state that you should pass a valid value (so none of the above) but being kernel handles they must be validated > Otherwise, > > Acked-by: Christophe de Dinechin <dinechin@xxxxxxxxxx> > > > > This utility will be reused in next patch. > > > > Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> > > --- > > vdagent/vdagent.cpp | 11 ++++++++++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp > > index def3508..e9bd77d 100644 > > --- a/vdagent/vdagent.cpp > > +++ b/vdagent/vdagent.cpp > > @@ -110,6 +110,7 @@ private: > > bool write_message(uint32_t type, uint32_t size, void* data); > > bool write_clipboard(VDAgentMessage* msg, uint32_t size); > > bool init_vio_serial(); > > + void close_vio_serial(); > > bool send_input(); > > void set_display_depth(uint32_t depth); > > void load_display_setting(); > > @@ -343,7 +344,7 @@ bool VDAgent::run() > > > > void VDAgent::cleanup() > > { > > - CloseHandle(_vio_serial); > > + close_vio_serial(); > > } > > > > void VDAgent::set_control_event(control_command_t control_command) > > @@ -1227,6 +1228,14 @@ bool VDAgent::init_vio_serial() > > return true; > > } > > > > +void VDAgent::close_vio_serial() > > +{ > > + if (_vio_serial != INVALID_HANDLE_VALUE) { > > + CloseHandle(_vio_serial); > > + _vio_serial = INVALID_HANDLE_VALUE; > > + } > > +} > > + > > void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port) > > { > > bool res = true; Frediano _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel