From 1d90c31ea2db25a81e510ecdd639952f162d0b00 Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Wed, 4 Aug 2004 16:39:09 +0000 Subject: [PATCH] Follow the InitCheck() model. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8537 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../transports/usb_port/print_transport.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/add-ons/print/transports/usb_port/print_transport.cpp b/src/add-ons/print/transports/usb_port/print_transport.cpp index a442086a0e..615f02c1dc 100644 --- a/src/add-ons/print/transports/usb_port/print_transport.cpp +++ b/src/add-ons/print/transports/usb_port/print_transport.cpp @@ -50,7 +50,7 @@ class UsbPort : public BDataIO { UsbPort(BDirectory* printer, BMessage* msg); ~UsbPort(); - bool IsOk() { return fFile > -1; } + bool InitCheck() { return fFile > -1; } ssize_t Read(void* buffer, size_t size); ssize_t Write(const void* buffer, size_t size); @@ -64,13 +64,11 @@ class UsbPort : public BDataIO { BDataIO* instanciate_transport(BDirectory* printer, BMessage* msg) { UsbPort* transport = new UsbPort(printer, msg); - if (transport->IsOk()) { - if (msg) - msg->what = 'okok'; + if (transport->InitCheck()) return transport; - } else { - delete transport; return NULL; - } + + delete transport; + return NULL; } @@ -111,6 +109,8 @@ UsbPort::UsbPort(BDirectory* printer, BMessage *msg) return; // Fill up the message + msg->what = 'okok'; + msg->AddBool("bidirectional", bidirectional); msg->AddString("device_id", device_id); @@ -131,10 +131,8 @@ UsbPort::UsbPort(BDirectory* printer, BMessage *msg) UsbPort::~UsbPort() { - if (IsOk()) { + if (fFile > -1) close(fFile); - fFile = -1; - } }