mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #4259 from LMESTM/fix_Stream_issue687
Add error check in Stream constructorpull/4274/head
commit
8543279901
|
@ -14,6 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "platform/Stream.h"
|
||||
#include "platform/mbed_error.h"
|
||||
#include <errno.h>
|
||||
|
||||
namespace mbed {
|
||||
|
||||
|
@ -23,7 +25,11 @@ Stream::Stream(const char *name) : FileLike(name), _file(NULL) {
|
|||
char buf[12]; /* :0x12345678 + null byte */
|
||||
std::sprintf(buf, ":%p", this);
|
||||
_file = std::fopen(buf, "w+");
|
||||
mbed_set_unbuffered_stream(_file);
|
||||
if (_file) {
|
||||
mbed_set_unbuffered_stream(_file);
|
||||
} else {
|
||||
error("Stream obj failure, errno=%d\r\n", errno);
|
||||
}
|
||||
}
|
||||
|
||||
Stream::~Stream() {
|
||||
|
|
Loading…
Reference in New Issue