forked from pool/mtdev
Stefan Dirsch
bbefaa00c6
OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/mtdev?expand=0&rev=2
49 lines
1.1 KiB
Diff
49 lines
1.1 KiB
Diff
From 61684cf0466200631b6a44af1c662eb760ad3f5d Mon Sep 17 00:00:00 2001
|
|
From: Peter Hutterer <peter.hutterer@who-t.net>
|
|
Date: Tue, 19 Apr 2011 11:41:04 +0200
|
|
Subject: [PATCH 1/2] mtdev_close should ignore NULL devices.
|
|
|
|
Saves us one goto label in mtdev_init.
|
|
|
|
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
|
|
---
|
|
src/core.c | 12 +++++++-----
|
|
1 files changed, 7 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/core.c b/src/core.c
|
|
index 1f7c1fe..07bc828 100644
|
|
--- a/src/core.c
|
|
+++ b/src/core.c
|
|
@@ -365,11 +365,11 @@ int mtdev_open(struct mtdev *dev, int fd)
|
|
goto error;
|
|
ret = mtdev_configure(dev, fd);
|
|
if (ret)
|
|
- goto mtdev;
|
|
+ goto error;
|
|
return 0;
|
|
- mtdev:
|
|
- mtdev_close(dev);
|
|
+
|
|
error:
|
|
+ mtdev_close(dev);
|
|
return ret;
|
|
}
|
|
|
|
@@ -411,8 +411,10 @@ void mtdev_close_delete(struct mtdev *dev)
|
|
|
|
void mtdev_close(struct mtdev *dev)
|
|
{
|
|
- free(dev->state);
|
|
- memset(dev, 0, sizeof(struct mtdev));
|
|
+ if (dev) {
|
|
+ free(dev->state);
|
|
+ memset(dev, 0, sizeof(struct mtdev));
|
|
+ }
|
|
}
|
|
|
|
void mtdev_delete(struct mtdev *dev)
|
|
--
|
|
1.7.6
|
|
|