cfs-coffee: examples: Fix coding style
This commit is contained in:
parent
4ed5c50a4e
commit
e23c175699
@ -28,31 +28,31 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \file
|
||||
* Example on how to use CFS/Coffee.
|
||||
* \author
|
||||
* Nicolas Tsiftes <nvt@sics.se>
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "contiki.h"
|
||||
#include "cfs/cfs.h"
|
||||
#include "cfs/cfs-coffee.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(example_coffee_process, "Coffee example");
|
||||
AUTOSTART_PROCESSES(&example_coffee_process);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define FILENAME "test"
|
||||
|
||||
/* Formatting is needed if the storage device is in an unknown state;
|
||||
/* Formatting is needed if the storage device is in an unknown state;
|
||||
e.g., when using Coffee on the storage device for the first time. */
|
||||
#ifndef NEED_FORMATTING
|
||||
#define NEED_FORMATTING 0
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
file_test(const char *filename, char *msg)
|
||||
{
|
||||
@ -65,12 +65,12 @@ file_test(const char *filename, char *msg)
|
||||
} record;
|
||||
|
||||
/*
|
||||
* Coffee determines the file length by finding the last non-zero byte
|
||||
* of the file. This I/O semantic requires that each record should end
|
||||
* with a non-zero, if we are writing multiple records and closing the
|
||||
* Coffee determines the file length by finding the last non-zero byte
|
||||
* of the file. This I/O semantic requires that each record should end
|
||||
* with a non-zero, if we are writing multiple records and closing the
|
||||
* file descriptor in between.
|
||||
*
|
||||
* In this example, in which the file_test function can be called
|
||||
* In this example, in which the file_test function can be called
|
||||
* multiple times, we ensure that the sequence counter starts at 1.
|
||||
*/
|
||||
|
||||
@ -84,7 +84,7 @@ file_test(const char *filename, char *msg)
|
||||
record.message[sizeof(record.message) - 1] = '\0';
|
||||
record.sequence = sequence;
|
||||
|
||||
/* Obtain a file descriptor for the file, capable of handling both
|
||||
/* Obtain a file descriptor for the file, capable of handling both
|
||||
reads and writes. */
|
||||
fd = cfs_open(FILENAME, CFS_WRITE | CFS_APPEND | CFS_READ);
|
||||
if(fd < 0) {
|
||||
@ -103,7 +103,7 @@ file_test(const char *filename, char *msg)
|
||||
printf("Wrote message \"%s\", sequence %u\n",
|
||||
record.message, record.sequence);
|
||||
|
||||
/* To read back the message, we need to move the file pointer to the
|
||||
/* To read back the message, we need to move the file pointer to the
|
||||
beginning of the file. */
|
||||
if(cfs_seek(fd, 0, CFS_SEEK_SET) != 0) {
|
||||
printf("seek failed\n");
|
||||
@ -133,7 +133,7 @@ file_test(const char *filename, char *msg)
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
dir_test(void)
|
||||
{
|
||||
@ -156,7 +156,7 @@ dir_test(void)
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(example_coffee_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
@ -29,19 +29,18 @@
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \file
|
||||
* A quick program for testing the CFS xmem driver
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "cfs/cfs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(cfs_process, "Test CFS process");
|
||||
AUTOSTART_PROCESSES(&cfs_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -29,14 +29,14 @@
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \file
|
||||
* Basic test for CFS/Coffee.
|
||||
* \author
|
||||
* Nicolas Tsiftes <nvt@sics.se>
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "cfs/cfs.h"
|
||||
#include "cfs/cfs-coffee.h"
|
||||
@ -45,14 +45,12 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(testcoffee_process, "Test CFS/Coffee process");
|
||||
AUTOSTART_PROCESSES(&testcoffee_process);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define TEST_FAIL(x) error = (x); goto end;
|
||||
|
||||
#define FILE_SIZE 4096
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
coffee_test_basic(void)
|
||||
@ -220,7 +218,7 @@ coffee_test_append(void)
|
||||
cfs_close(afd);
|
||||
}
|
||||
|
||||
/* Test 3-6: Read back the data written previously and verify that it
|
||||
/* Test 3-6: Read back the data written previously and verify that it
|
||||
is correct. */
|
||||
afd = cfs_open("T3", CFS_READ);
|
||||
if(afd < 0) {
|
||||
@ -376,7 +374,7 @@ PROCESS_THREAD(testcoffee_process, ev, data)
|
||||
result = coffee_test_gc();
|
||||
print_result("Garbage collection", result);
|
||||
|
||||
printf("Coffee test finished. Duration: %d seconds\n",
|
||||
printf("Coffee test finished. Duration: %d seconds\n",
|
||||
(int)(clock_seconds() - start));
|
||||
|
||||
PROCESS_END();
|
||||
|
Loading…
Reference in New Issue
Block a user