mirror of
https://github.com/team-infusion-developers/android_hardware_samsung.git
synced 2024-11-06 21:55:41 +00:00
lights: Put back fd checks before closing
While close(NULL) is indeed a harmless noop, fd can end up being < 0 for us. Change-Id: I56dcd7fb61c72d3ce750b13329ff42e11ab63c84
This commit is contained in:
parent
235c298767
commit
e37aedde2e
1 changed files with 6 additions and 4 deletions
|
@ -31,7 +31,7 @@
|
||||||
* Reads an Integer from a file.
|
* Reads an Integer from a file.
|
||||||
*
|
*
|
||||||
* @param path The absolute path string.
|
* @param path The absolute path string.
|
||||||
* @return The Integer with decimal base, -1 or errno on error.
|
* @return The Integer with decimal base, -1 or -errno on error.
|
||||||
*/
|
*/
|
||||||
static int read_int(char const *path)
|
static int read_int(char const *path)
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,8 @@ static int read_int(char const *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
close(fd);
|
if (fd >= 0)
|
||||||
|
close(fd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ exit:
|
||||||
*
|
*
|
||||||
* @param path The absolute path string.
|
* @param path The absolute path string.
|
||||||
* @param value The Integer value to be written.
|
* @param value The Integer value to be written.
|
||||||
* @return 0 on success, errno on error.
|
* @return 0 on success, -errno on error.
|
||||||
*/
|
*/
|
||||||
static int write_int(char const *path, const int value)
|
static int write_int(char const *path, const int value)
|
||||||
{
|
{
|
||||||
|
@ -100,7 +101,8 @@ static int write_int(char const *path, const int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
close(fd);
|
if (fd >= 0)
|
||||||
|
close(fd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue