src/file_fds.c: add frama-c annotations

This commit is contained in:
Christophe Grenier 2021-02-20 15:05:38 +01:00
parent b7b5fc5c4e
commit 1212037a51

View file

@ -32,8 +32,8 @@
#include "filegen.h"
#include "common.h"
/*@ requires \valid(file_stat); */
static void register_header_check_fds(file_stat_t *file_stat);
static int header_check_fds(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
const file_hint_t file_hint_fds= {
.extension="fds",
@ -50,6 +50,17 @@ struct fds_header
uint8_t numsides;
} __attribute__ ((gcc_struct, __packed__));
/*@
@ requires buffer_size > 0;
@ requires \valid_read(buffer+(0..buffer_size-1));
@ requires valid_file_recovery(file_recovery);
@ requires \valid(file_recovery_new);
@ requires file_recovery_new->blocksize > 0;
@ requires separation: \separated(&file_hint_fds, buffer+(..), file_recovery, file_recovery_new);
@ ensures \result == 0 || \result == 1;
@ ensures \result!=0 ==> valid_file_recovery(file_recovery_new);
@ assigns *file_recovery_new;
@*/
static int header_check_fds(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
const struct fds_header *bm=(const struct fds_header *)buffer;
@ -57,7 +68,7 @@ static int header_check_fds(const unsigned char *buffer, const unsigned int buff
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_fds.extension;
file_recovery_new->min_filesize=16;
file_recovery_new->calculated_file_size=(uint64_t)size;
file_recovery_new->calculated_file_size=size;
file_recovery_new->data_check=&data_check_size;
file_recovery_new->file_check=&file_check_size;
return 1;