cfs-coffee: examples: Fix coding style
This commit is contained in:
parent
4ed5c50a4e
commit
e23c175699
3 changed files with 23 additions and 26 deletions
|
@ -28,31 +28,31 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*/
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* Example on how to use CFS/Coffee.
|
* Example on how to use CFS/Coffee.
|
||||||
* \author
|
* \author
|
||||||
* Nicolas Tsiftes <nvt@sics.se>
|
* Nicolas Tsiftes <nvt@sics.se>
|
||||||
*/
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "cfs/cfs.h"
|
#include "cfs/cfs.h"
|
||||||
#include "cfs/cfs-coffee.h"
|
#include "cfs/cfs-coffee.h"
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS(example_coffee_process, "Coffee example");
|
PROCESS(example_coffee_process, "Coffee example");
|
||||||
AUTOSTART_PROCESSES(&example_coffee_process);
|
AUTOSTART_PROCESSES(&example_coffee_process);
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
#define FILENAME "test"
|
#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. */
|
e.g., when using Coffee on the storage device for the first time. */
|
||||||
#ifndef NEED_FORMATTING
|
#ifndef NEED_FORMATTING
|
||||||
#define NEED_FORMATTING 0
|
#define NEED_FORMATTING 0
|
||||||
#endif
|
#endif
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
file_test(const char *filename, char *msg)
|
file_test(const char *filename, char *msg)
|
||||||
{
|
{
|
||||||
|
@ -65,12 +65,12 @@ file_test(const char *filename, char *msg)
|
||||||
} record;
|
} record;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Coffee determines the file length by finding the last non-zero byte
|
* 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
|
* 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
|
* with a non-zero, if we are writing multiple records and closing the
|
||||||
* file descriptor in between.
|
* 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.
|
* 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.message[sizeof(record.message) - 1] = '\0';
|
||||||
record.sequence = sequence;
|
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. */
|
reads and writes. */
|
||||||
fd = cfs_open(FILENAME, CFS_WRITE | CFS_APPEND | CFS_READ);
|
fd = cfs_open(FILENAME, CFS_WRITE | CFS_APPEND | CFS_READ);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
|
@ -103,7 +103,7 @@ file_test(const char *filename, char *msg)
|
||||||
printf("Wrote message \"%s\", sequence %u\n",
|
printf("Wrote message \"%s\", sequence %u\n",
|
||||||
record.message, record.sequence);
|
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. */
|
beginning of the file. */
|
||||||
if(cfs_seek(fd, 0, CFS_SEEK_SET) != 0) {
|
if(cfs_seek(fd, 0, CFS_SEEK_SET) != 0) {
|
||||||
printf("seek failed\n");
|
printf("seek failed\n");
|
||||||
|
@ -133,7 +133,7 @@ file_test(const char *filename, char *msg)
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
dir_test(void)
|
dir_test(void)
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,7 @@ dir_test(void)
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS_THREAD(example_coffee_process, ev, data)
|
PROCESS_THREAD(example_coffee_process, ev, data)
|
||||||
{
|
{
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
|
@ -29,19 +29,18 @@
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* A quick program for testing the CFS xmem driver
|
* A quick program for testing the CFS xmem driver
|
||||||
* \author
|
* \author
|
||||||
* Adam Dunkels <adam@sics.se>
|
* Adam Dunkels <adam@sics.se>
|
||||||
*/
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "cfs/cfs.h"
|
#include "cfs/cfs.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS(cfs_process, "Test CFS process");
|
PROCESS(cfs_process, "Test CFS process");
|
||||||
AUTOSTART_PROCESSES(&cfs_process);
|
AUTOSTART_PROCESSES(&cfs_process);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -29,14 +29,14 @@
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* Basic test for CFS/Coffee.
|
* Basic test for CFS/Coffee.
|
||||||
* \author
|
* \author
|
||||||
* Nicolas Tsiftes <nvt@sics.se>
|
* Nicolas Tsiftes <nvt@sics.se>
|
||||||
*/
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "cfs/cfs.h"
|
#include "cfs/cfs.h"
|
||||||
#include "cfs/cfs-coffee.h"
|
#include "cfs/cfs-coffee.h"
|
||||||
|
@ -45,14 +45,12 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS(testcoffee_process, "Test CFS/Coffee process");
|
PROCESS(testcoffee_process, "Test CFS/Coffee process");
|
||||||
AUTOSTART_PROCESSES(&testcoffee_process);
|
AUTOSTART_PROCESSES(&testcoffee_process);
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
#define TEST_FAIL(x) error = (x); goto end;
|
#define TEST_FAIL(x) error = (x); goto end;
|
||||||
|
|
||||||
#define FILE_SIZE 4096
|
#define FILE_SIZE 4096
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
coffee_test_basic(void)
|
coffee_test_basic(void)
|
||||||
|
@ -220,7 +218,7 @@ coffee_test_append(void)
|
||||||
cfs_close(afd);
|
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. */
|
is correct. */
|
||||||
afd = cfs_open("T3", CFS_READ);
|
afd = cfs_open("T3", CFS_READ);
|
||||||
if(afd < 0) {
|
if(afd < 0) {
|
||||||
|
@ -376,7 +374,7 @@ PROCESS_THREAD(testcoffee_process, ev, data)
|
||||||
result = coffee_test_gc();
|
result = coffee_test_gc();
|
||||||
print_result("Garbage collection", result);
|
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));
|
(int)(clock_seconds() - start));
|
||||||
|
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
|
|
Loading…
Add table
Reference in a new issue