uint8_t GoalModel::getstepvalue()
{
int stepgoal = step_goal;
+ if (stepgoal <= 0)
+ {
+ return 0;
+ }
int stepdata = show_data_step_refresh();//cywee_get_step_data();//OHOS::ActivityModel::GetInstance()->GetStepCounter();
// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %d %f ",stepdata,stepgoal,((float)stepdata/(float)stepgoal) * 100);
uint8_t value = ((float)stepdata / (float)stepgoal) * 100;
{
return 0;
}
+ if (size == 0 || (size % 8) != 0)
+ {
+ fclose(fp);
+ return 0;
+ }
uint8_t *date=(uint8_t *)malloc(size);
- if(date==NULL) return 0;
+ if(date==NULL) {
+ fclose(fp);
+ return 0;
+ }
- fread(date,sizeof(uint8_t),size,fp);
+ size_t readSize = fread(date,sizeof(uint8_t),size,fp);
fclose(fp);
+ if (readSize != size)
+ {
+ free(date);
+ return 0;
+ }
int32_t sing_date=0;
int32_t timetemp=0;
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %d", sing_date);
- struct tm *timeinfo;
- timeinfo = localtime((time_t *) &timetemp);
+ time_t ts = static_cast<time_t>(timetemp);
+ struct tm *timeinfo = localtime(&ts);
+ if (timeinfo == nullptr)
+ {
+ continue;
+ }
if(sing_date>0 && timeinfo->tm_mday==day_now && timeinfo->tm_mon==mon_now)
{
return 0;
}
+ if (size == 0 || (size % 8) != 0)
+ {
+ fclose(fp);
+ return 0;
+ }
uint8_t *date=(uint8_t *)malloc(size);
- if(date==NULL) return 0;
+ if(date==NULL) {
+ fclose(fp);
+ return 0;
+ }
- fread(date,sizeof(uint8_t),size,fp);
+ size_t readSize = fread(date,sizeof(uint8_t),size,fp);
fclose(fp);
+ if (readSize != size)
+ {
+ free(date);
+ return 0;
+ }
float sing_date=0;
int32_t timetemp=0;
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %f", sing_date);
- struct tm *timeinfo;
- timeinfo = localtime((time_t *) &timetemp);
+ time_t ts = static_cast<time_t>(timetemp);
+ struct tm *timeinfo = localtime(&ts);
+ if (timeinfo == nullptr)
+ {
+ continue;
+ }
if(sing_date>0 && timeinfo->tm_mday==day_now && timeinfo->tm_mon==mon_now)
{
return 0;
}
+ if (size == 0 || (size % 8) != 0)
+ {
+ fclose(fp);
+ return 0;
+ }
uint8_t *date=(uint8_t *)malloc(size);
- if(date==NULL) return 0;
+ if(date==NULL) {
+ fclose(fp);
+ return 0;
+ }
- fread(date,sizeof(uint8_t),size,fp);
+ size_t readSize = fread(date,sizeof(uint8_t),size,fp);
fclose(fp);
+ if (readSize != size)
+ {
+ free(date);
+ return 0;
+ }
float sing_date=0;
int32_t timetemp=0;
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp);
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "data: %f", sing_date);
- struct tm *timeinfo;
- timeinfo = localtime((time_t *) &timetemp);
+ time_t ts = static_cast<time_t>(timetemp);
+ struct tm *timeinfo = localtime(&ts);
+ if (timeinfo == nullptr)
+ {
+ continue;
+ }
if(sing_date>0 && timeinfo->tm_mday==day_now && timeinfo->tm_mon==mon_now)
{
return 0;
}
+ if (size == 0 || (size % 6) != 0)
+ {
+ fclose(fp);
+ return 0;
+ }
uint8_t *date=(uint8_t *)malloc(size);
- if(date==NULL) return 0;
+ if(date==NULL) {
+ fclose(fp);
+ return 0;
+ }
- fread(date,sizeof(uint8_t),size,fp);
+ size_t readSize = fread(date,sizeof(uint8_t),size,fp);
fclose(fp);
+ if (readSize != size)
+ {
+ free(date);
+ return 0;
+ }
uint16 sing_date=0;
int32_t timetemp=0;
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %d", sing_date);
- struct tm *timeinfo;
- timeinfo = localtime((time_t *) &timetemp);
+ time_t ts = static_cast<time_t>(timetemp);
+ struct tm *timeinfo = localtime(&ts);
+ if (timeinfo == nullptr)
+ {
+ continue;
+ }
if(sing_date>0 && timeinfo->tm_mday==day_now && timeinfo->tm_mon==mon_now)