Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow C89 compilations (fix lint warnings)

Change-Id: I80bb252161375d8773ff5142bd2bffa46a7bf401
Reviewed-on: http://review.couchbase.org/15962
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
  • Loading branch information...
commit 56ce0a2045db8ddb07a8922aef44609e1edd03b8 1 parent c8b3222
@trondn trondn authored chiyoung committed
View
3  .gitignore
@@ -1,8 +1,7 @@
# Keep the entries sorted to reduce the risk for a merge conflict
*.[ao]
*.dll
-*.la
-*.lo
+*.l[aon]
*.exe
*.exp
*.lib
View
2  Makefile.am
@@ -53,7 +53,7 @@ if !HAVE_GOOGLETEST_SRC
tests_cbio_unit_tests_LDADD += -lgtest
endif
-LINTFLAGS=-Iinclude -b -c -errchk=%all \
+LINTFLAGS=-DLIBCBIO_INTERNAL=1 -Iinclude -b -c -errchk=%all \
-erroff=E_INCL_NUSD,E_CAST_INT_TO_SMALL_INT,E_PTRDIFF_OVERFLOW \
-errtags=yes -errhdr=%user \
-errsecurity=extended -fd -Ncheck=%all -Nlevel=4 -n -Xc99=none
View
2  configure.ac
@@ -33,7 +33,7 @@ AC_CONFIG_MACRO_DIR([m4])
ac_cv_func_malloc_0_nonnull=yes
ac_cv_func_realloc_0_nonnull=yes
-COUCHBASE_GENERIC_COMPILER(c99)
+COUCHBASE_GENERIC_COMPILER(c89)
AM_CPPFLAGS="$AM_CPPFLAGS -I\${top_srcdir}/src"
LIBCBIO_API_CURRENT=1
View
4 src/document.c
@@ -31,10 +31,12 @@ LIBCBIO_API
cbio_error_t cbio_create_empty_document(libcbio_t handle,
libcbio_document_t *doc)
{
+ libcbio_document_t ret;
if (doc == NULL) {
return CBIO_ERROR_EINVAL;
}
- libcbio_document_t ret = calloc(1, sizeof(*ret));
+
+ ret = calloc(1, sizeof(*ret));
(void)handle;
*doc = ret;
if (*doc != NULL) {
View
32 src/instance.c
@@ -46,7 +46,7 @@ cbio_error_t cbio_open_handle(const char *name,
ret->mode = mode;
if (mode == CBIO_OPEN_RDONLY) {
flags = COUCHSTORE_OPEN_FLAG_RDONLY;
- } else if (CBIO_OPEN_CREATE) {
+ } else if (mode == CBIO_OPEN_CREATE) {
flags = COUCHSTORE_OPEN_FLAG_CREATE;
} else {
flags = 0;
@@ -76,6 +76,7 @@ void cbio_close_handle(libcbio_t handle)
LIBCBIO_API
off_t cbio_get_header_position(libcbio_t handle)
{
+ /* LINTED */
return (off_t)couchstore_get_header_position(handle->couchstore_handle);
}
@@ -118,12 +119,14 @@ cbio_error_t cbio_get_document(libcbio_t handle,
size_t nid,
libcbio_document_t *doc)
{
+ libcbio_document_t ret;
+ couchstore_error_t err;
+
if (cbio_is_local_id(id, nid)) {
return cbio_get_local_document(handle, id, nid, doc);
}
- libcbio_document_t ret = calloc(1, sizeof(*ret));
- couchstore_error_t err;
+ ret = calloc(1, sizeof(*ret));
if (ret == NULL) {
return CBIO_ERROR_ENOMEM;
@@ -152,13 +155,14 @@ cbio_error_t cbio_get_document_ex(libcbio_t handle,
size_t nid,
libcbio_document_t *doc)
{
+ libcbio_document_t ret;
+ couchstore_error_t err;
+
if (cbio_is_local_id(id, nid)) {
return cbio_get_local_document(handle, id, nid, doc);
}
- libcbio_document_t ret = calloc(1, sizeof(*ret));
- couchstore_error_t err;
-
+ ret = calloc(1, sizeof(*ret));
if (ret == NULL) {
return CBIO_ERROR_ENOMEM;
}
@@ -186,7 +190,8 @@ static cbio_error_t cbio_store_local_documents(libcbio_t handle,
libcbio_document_t *doc,
size_t ndocs)
{
- for (size_t ii = 0; ii < ndocs; ++ii) {
+ size_t ii;
+ for (ii = 0; ii < ndocs; ++ii) {
couchstore_error_t err;
LocalDoc mydoc;
mydoc.id = doc[ii]->info->id;
@@ -241,7 +246,7 @@ cbio_error_t cbio_store_documents(libcbio_t handle,
}
err = couchstore_save_documents(handle->couchstore_handle, docs, info,
- ndocs, 0);
+ (unsigned int)ndocs, 0);
free(docs);
free(info);
@@ -265,7 +270,6 @@ struct cbio_wrap_ctx {
static int couchstore_changes_callback(Db *db, DocInfo *docinfo, void *ctx)
{
- (void)db;
int ret = 0;
libcbio_document_t doc = calloc(1, sizeof(*doc));
if (doc) {
@@ -279,6 +283,7 @@ static int couchstore_changes_callback(Db *db, DocInfo *docinfo, void *ctx)
}
}
+ (void)db;
return ret;
}
@@ -288,11 +293,12 @@ cbio_error_t cbio_changes_since(libcbio_t handle,
cbio_changes_callback_fn callback,
void *ctx)
{
- struct cbio_wrap_ctx uctx = { .callback = callback,
- .handle = handle,
- .ctx = ctx
- };
+ struct cbio_wrap_ctx uctx;
couchstore_error_t err;
+ uctx.callback = callback;
+ uctx.handle = handle;
+ uctx.ctx = ctx;
+
err = couchstore_changes_since(handle->couchstore_handle,
since, 0,
couchstore_changes_callback,
View
14 tests/instance_unit_tests.cc
@@ -81,7 +81,7 @@ TEST_F(LibcbioOpenTest, HandleNullNameOpenRW)
cbio_open_handle(NULL, CBIO_OPEN_RW, &handle));
}
-TEST_F(LibcbioOpenTest, HandleNonexistentNameOpenRW)
+TEST_F(LibcbioOpenTest, HandleNonexistentPathNameOpenRW)
{
libcbio_t handle;
EXPECT_EQ(CBIO_ERROR_ENOENT,
@@ -89,6 +89,18 @@ TEST_F(LibcbioOpenTest, HandleNonexistentNameOpenRW)
CBIO_OPEN_RW, &handle));
}
+TEST_F(LibcbioOpenTest, HandleNonexistentNameOpenRW)
+{
+ libcbio_t handle;
+ int error = remove("missing-db");
+ if (error == -1) {
+ EXPECT_EQ(ENOENT, errno);
+ }
+ EXPECT_EQ(CBIO_ERROR_ENOENT,
+ cbio_open_handle("missing-db",
+ CBIO_OPEN_RW, &handle));
+}
+
TEST_F(LibcbioOpenTest, HandleEmptyNameOpenCREATE)
{
libcbio_t handle;
Please sign in to comment.
Something went wrong with that request. Please try again.