formatting fixup

This commit is contained in:
Martin Schröder 2016-09-11 00:29:24 +02:00
parent d8f7e32338
commit 259abafe80
11 changed files with 54 additions and 23 deletions

View file

@ -3,3 +3,5 @@ ACLOCAL_AMFLAGS=-I m4
SUBDIRS=src test
EXTRA_DIST=autogen.mk
test: check

View file

@ -3,4 +3,10 @@ includedir=$(prefix)/include/blobpack/
lib_LTLIBRARIES=libblobpack.la
include_HEADERS=blobpack.h blob.h blob_field.h blob_json.h utils.h
libblobpack_la_SOURCES=blob.c blob_field.c blob_json.c blob_ujson.c ujsondec.c ujsonenc.c utils.c
libblobpack_la_CFLAGS=$(CODE_COVERAGE_CFLAGS) -std=gnu99 -Wall -Werror
libblobpack_la_CFLAGS=$(CODE_COVERAGE_CFLAGS) -std=gnu99 -Wall -Werror -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes \
-Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \
-Wshadow -Wcast-align -Wchar-subscripts -Winline \
-Wnested-externs -Wredundant-decls -Wmissing-field-initializers -Wextra \
-Wformat=2 -Wno-format-nonliteral -Wpointer-arith -Wno-missing-braces \
-Wno-unused-parameter -Wno-unused-variable -Wno-inline

View file

@ -323,7 +323,13 @@ top_srcdir = @top_srcdir@
lib_LTLIBRARIES = libblobpack.la
include_HEADERS = blobpack.h blob.h blob_field.h blob_json.h utils.h
libblobpack_la_SOURCES = blob.c blob_field.c blob_json.c blob_ujson.c ujsondec.c ujsonenc.c utils.c
libblobpack_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) -std=gnu99 -Wall -Werror
libblobpack_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) -std=gnu99 -Wall -Werror -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes \
-Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \
-Wshadow -Wcast-align -Wchar-subscripts -Winline \
-Wnested-externs -Wredundant-decls -Wmissing-field-initializers -Wextra \
-Wformat=2 -Wno-format-nonliteral -Wpointer-arith -Wno-missing-braces \
-Wno-unused-parameter -Wno-unused-variable -Wno-inline
all: all-am
.SUFFIXES:

View file

@ -129,7 +129,7 @@ static bool blob_puts(struct strbuf *s, const char *c, int len)
static void add_separator(struct strbuf *s)
{
static char indent_chars[17] = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
char indent_chars[17] = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
int indent;
char *start;
@ -348,12 +348,12 @@ static void _blob_field_dump_json(const struct blob_field *self, int indent){
}
void blob_field_dump_json(const struct blob_field *self){
assert(self);
if(!self) return;
_blob_field_dump_json(self, 0);
}
void blob_field_dump_json_pretty(const struct blob_field *self){
assert(self);
if(!self) return;
_blob_field_dump_json(self, 1);
}

View file

@ -200,12 +200,13 @@ bool blob_put_json_from_file(struct blob *self, const char *file){
lseek(fd, SEEK_SET, 0);
char *buffer = malloc(file_size + 1); // allocate on stack
memset(buffer, 0, file_size + 1);
if(file_size != read(fd, buffer, file_size)){
int ret = 0;
if((ret = read(fd, buffer, file_size)) > 0 && (size_t)ret != file_size){
close(fd);
return false;
}
close(fd);
int ret = blob_put_json(self, buffer);
ret = blob_put_json(self, buffer);
free(buffer);
return ret;
}

View file

@ -1,15 +1,21 @@
@CODE_COVERAGE_RULES@
check_PROGRAMS=random read-write json parse
AM_CFLAGS=$(CODE_COVERAGE_CFLAGS) -Wall -Werror -fPIC -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes \
-Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \
-Wshadow -Wcast-align -Wchar-subscripts -Winline \
-Wnested-externs -Wredundant-decls -Wmissing-field-initializers -Wextra \
-Wformat=2 -Wno-format-nonliteral -Wpointer-arith -Wno-missing-braces \
-Wno-unused-parameter -Wno-unused-variable -Wno-inline -I../src/ -std=c99 -D_GNU_SOURCE
random_SOURCES=random.c
random_CFLAGS=$(CODE_COVERAGE_CFLAGS) -I../src/ -std=c99
random_CFLAGS=$(AM_CFLAGS)
random_LDFLAGS=$(CODE_COVERAGE_LDFLAGS) -L../src/.libs/ -lblobpack -lm
read_write_SOURCES=read-write.c
read_write_CFLAGS=$(CODE_COVERAGE_CFLAGS) -I../src/ -D_GNU_SOURCE -std=c99
read_write_CFLAGS=$(AM_CFLAGS)
read_write_LDFLAGS=$(CODE_COVERAGE_LDFLAGS) -L../src/.libs/ -lblobpack -lm
json_SOURCES=json.c
json_CFLAGS=$(CODE_COVERAGE_CFLAGS) -I../src/ -D_GNU_SOURCE -std=c99
json_CFLAGS=$(AM_CFLAGS)
json_LDFLAGS=$(CODE_COVERAGE_LDFLAGS) -L../src/.libs/ -lblobpack -lm
parse_SOURCES=parse.c
parse_CFLAGS=$(CODE_COVERAGE_CFLAGS) -I../src/ -D_GNU_SOURCE -std=c99
parse_CFLAGS=$(AM_CFLAGS)
parse_LDFLAGS=$(CODE_COVERAGE_LDFLAGS) -L../src/.libs/ -lblobpack -lm
TESTS=$(check_PROGRAMS)

View file

@ -510,17 +510,24 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) -Wall -Werror -fPIC -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes \
-Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \
-Wshadow -Wcast-align -Wchar-subscripts -Winline \
-Wnested-externs -Wredundant-decls -Wmissing-field-initializers -Wextra \
-Wformat=2 -Wno-format-nonliteral -Wpointer-arith -Wno-missing-braces \
-Wno-unused-parameter -Wno-unused-variable -Wno-inline -I../src/ -std=c99 -D_GNU_SOURCE
random_SOURCES = random.c
random_CFLAGS = $(CODE_COVERAGE_CFLAGS) -I../src/ -std=c99
random_CFLAGS = $(AM_CFLAGS)
random_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) -L../src/.libs/ -lblobpack -lm
read_write_SOURCES = read-write.c
read_write_CFLAGS = $(CODE_COVERAGE_CFLAGS) -I../src/ -D_GNU_SOURCE -std=c99
read_write_CFLAGS = $(AM_CFLAGS)
read_write_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) -L../src/.libs/ -lblobpack -lm
json_SOURCES = json.c
json_CFLAGS = $(CODE_COVERAGE_CFLAGS) -I../src/ -D_GNU_SOURCE -std=c99
json_CFLAGS = $(AM_CFLAGS)
json_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) -L../src/.libs/ -lblobpack -lm
parse_SOURCES = parse.c
parse_CFLAGS = $(CODE_COVERAGE_CFLAGS) -I../src/ -D_GNU_SOURCE -std=c99
parse_CFLAGS = $(AM_CFLAGS)
parse_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) -L../src/.libs/ -lblobpack -lm
TESTS = $(check_PROGRAMS)
all: all-am

View file

@ -4,7 +4,7 @@
#include <math.h>
#include <memory.h>
int main(){
int main(void){
struct blob blob;
blob_init(&blob, 0, 0);
@ -33,7 +33,7 @@ int main(){
blob_put_int(&blob, 5000000000lu);
blob_close_array(&blob, o);
struct blob_field *out[8];
const struct blob_field *out[8];
TEST(blob_field_parse(blob_head(&blob), "isifssta", out, 8));
char *json = blob_to_json(&blob);

View file

@ -4,7 +4,7 @@
#include <math.h>
#include <memory.h>
int main(){
int main(void){
struct blob blob;
blob_init(&blob, 0, 0);
@ -13,7 +13,7 @@ int main(){
blob_put_int(&blob, -13);
blob_put_real(&blob, M_PI);
struct blob_field *out[4];
const struct blob_field *out[4];
blob_dump_json(&blob);

View file

@ -1,4 +1,7 @@
#include "blobpack.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
enum {
FIELD_STRING,

View file

@ -4,7 +4,7 @@
#include <math.h>
#include <memory.h>
int main(){
int main(void){
struct blob blob;
blob_init(&blob, 0, 0);
char data_in[] = {1, 2, 3, 4, 5, 6, 7};
@ -50,8 +50,8 @@ int main(){
blob_dump(&blob);
struct blob_field *root = blob_head(&blob);
struct blob_field *child = blob_field_first_child(root);
const struct blob_field *root = blob_head(&blob);
const struct blob_field *child = blob_field_first_child(root);
TEST(blob_field_get_bool(child) == true);
TEST(strcmp(blob_field_get_string(child = blob_field_next_child(root, child)), "foo") == 0);
@ -76,7 +76,7 @@ int main(){
// iterate over the list
child = blob_field_next_child(root, child);
struct blob_field *list = child;
const struct blob_field *list = child;
child = blob_field_first_child(child);
TEST(strcmp(blob_field_get_string(child), "one") == 0);