- (cp_begin - (uint8_t*)pi_file->po_info);
memcpy(po_del_pos, cp_begin, cp_sz);
+ int retval = 0;
pi_file->po_num--;
- int ret = ss_write((uint8_t*)pi_file->po_info, po_info_sz * pi_file->po_num,
- 0, pi_file->filename, &pi_file->cred, SS_OPT_DEFAULT);
- if (SS_RET_SUCCESS != ret) {
- MSG("Failed to write po stat to secure storage,ret = %d.", ret);
- __FREE(pi_file->po_info);
- return -1;
+ if (pi_file->po_num == 0) {
+ int ret = ss_delete(pi_file->filename, &pi_file->cred, SS_OPT_DEFAULT);
+ if (SS_RET_SUCCESS != ret) {
+ MSG("Failed to delete pi file,ret = %d.", ret);
+ retval = -1;
+ }
+ } else {
+ int ret = ss_write((uint8_t*)pi_file->po_info, po_info_sz * pi_file->po_num,
+ 0, pi_file->filename, &pi_file->cred, SS_OPT_DEFAULT);
+ if (SS_RET_SUCCESS != ret) {
+ MSG("Failed to write po stat to secure storage,ret = %d.", ret);
+ retval = -1;
+ }
}
__FREE(pi_file->po_info);
- return 0;
+ return retval;
}
persistent_object_info* find_po_info(po_info_file* pi_file,