OSDN Git Service

Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into mr1
[android-x86/hardware-intel-libsensors.git] / accel-calibration.c
index aa67ece..9367774 100644 (file)
@@ -181,7 +181,7 @@ void accel_cal_init (int s)
        }
 
        /* Fall back to initial values */
-       memset(cal_data, sizeof(accel_cal_t), 0);
+       memset(cal_data, 0, sizeof(accel_cal_t));
 
        /* Store the parameters that are used with that data set, so we can check them against future version of the code to prevent inadvertent reuse */
        cal_data->version          = (ACCEL_CALIB_DATA_VERSION << 16) + sizeof(accel_cal_t);
@@ -201,7 +201,8 @@ void accel_cal_store (int s)
 
        fd = open(ACCEL_CALIBRATION_PATH, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR);
 
-       write(fd, cal_data, sizeof(accel_cal_t));
-
-       close(fd);
+       if (fd != -1) {
+               write(fd, cal_data, sizeof(accel_cal_t));
+               close(fd);
+       }
 }