[vlc-commits] motionlib: fix potential file descriptor leak, set close-on-exec
Rémi Denis-Courmont
git at videolan.org
Sat Apr 12 16:03:05 CEST 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Apr 12 12:40:27 2014 +0300| [a3be08a37052f14cda17f9c0e6f3609f9ddcd878] | committer: Rémi Denis-Courmont
motionlib: fix potential file descriptor leak, set close-on-exec
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a3be08a37052f14cda17f9c0e6f3609f9ddcd878
---
modules/control/motionlib.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/modules/control/motionlib.c b/modules/control/motionlib.c
index 3853726..fd13f6f 100644
--- a/modules/control/motionlib.c
+++ b/modules/control/motionlib.c
@@ -71,7 +71,7 @@ motion_sensors_t *motion_create( vlc_object_t *obj )
}
if( access( "/sys/devices/platform/hdaps/position", R_OK ) == 0
- && ( f = fopen( "/sys/devices/platform/hdaps/calibrate", "r" ) ) )
+ && ( f = fopen( "/sys/devices/platform/hdaps/calibrate", "re" ) ) )
{
/* IBM HDAPS support */
motion->i_calibrate = fscanf( f, "(%d,%d)", &i_x, &i_y ) == 2 ? i_x: 0;
@@ -86,7 +86,7 @@ motion_sensors_t *motion_create( vlc_object_t *obj )
msg_Dbg( obj, "AMS motion detection correctly loaded" );
}
else if( access( "/sys/devices/platform/applesmc.768/position", R_OK ) == 0
- && ( f = fopen( "/sys/devices/platform/applesmc.768/calibrate", "r" ) ) )
+ && ( f = fopen( "/sys/devices/platform/applesmc.768/calibrate", "re" ) ) )
{
/* Apple SMC (newer macbooks) */
/* Should be factorised with HDAPS */
@@ -133,7 +133,7 @@ static int GetOrientation( motion_sensors_t *motion )
switch( motion->sensor )
{
case HDAPS_SENSOR:
- f = fopen( "/sys/devices/platform/hdaps/position", "r" );
+ f = fopen( "/sys/devices/platform/hdaps/position", "re" );
if( !f )
{
return 0;
@@ -148,7 +148,7 @@ static int GetOrientation( motion_sensors_t *motion )
return ( i_x - motion->i_calibrate ) * 10;
case AMS_SENSOR:
- f = fopen( "/sys/devices/ams/x", "r" );
+ f = fopen( "/sys/devices/ams/x", "re" );
if( !f )
{
return 0;
@@ -163,7 +163,7 @@ static int GetOrientation( motion_sensors_t *motion )
return - i_x * 30; /* FIXME: arbitrary */
case APPLESMC_SENSOR:
- f = fopen( "/sys/devices/platform/applesmc.768/position", "r" );
+ f = fopen( "/sys/devices/platform/applesmc.768/position", "re" );
if( !f )
{
return 0;
More information about the vlc-commits
mailing list