[Openais] [PATCH] toplevel "make lint"
angus salkeld
angus.salkeld at alliedtelesis.co.nz
Thu Oct 30 18:20:24 PDT 2008
Hi
Here is a toplevel "make lint".
There are still LOTS of warnings despite using the "-weak" option.
Regards
Angus
c file changes:
objdb:
remove all references to object_iter() & object_iter_reset() from the API
extern objdb_iface so it is not declared twice.
rename the array objdb_iface_ver0 for clarity (it is also a type)
totempg:
convert some assert (pointer) to assert (pointer != NULL)
in totempg_deliver_fn() move the assert above the top most usage of the pointer.
lint prefers snprintf
---
Makefile | 7 +++++++
Makefile.inc | 1 +
exec/Makefile | 3 +++
exec/apidef.c | 2 --
exec/objdb.c | 8 ++++----
exec/totempg.c | 12 +++++++-----
include/corosync/engine/coroapi.h | 9 ---------
include/corosync/engine/objdb.h | 9 ---------
lcr/Makefile | 3 +++
lib/Makefile | 3 +++
services/Makefile | 3 +++
tools/Makefile | 3 +++
12 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/Makefile b/Makefile
index e255234..3b1d6ac 100644
--- a/Makefile
+++ b/Makefile
@@ -115,6 +115,13 @@ clean:
(cd $(builddir)test; echo ==== `pwd` ===; $(call sub_make,test,clean));
rm -rf $(builddir)doc/api
+lint:
+ (cd $(builddir)exec; echo ==== `pwd` ===; $(call sub_make,exec,lint));
+ (cd $(builddir)services; echo ==== `pwd` ===; $(call sub_make,services,lint));
+ (cd $(builddir)lcr; echo ==== `pwd` ===; $(call sub_make,lcr,lint));
+ (cd $(builddir)lib; echo ==== `pwd` ===; $(call sub_make,lib,lint));
+ (cd $(builddir)tools; echo ==== `pwd` ===; $(call sub_make,tools,lint));
+
COROSYNC_LIBS = evs cpg cfg coroutil confdb
COROSYNC_HEADERS = cpg.h cfg.h evs.h ipc_gen.h mar_gen.h swab.h \
diff --git a/Makefile.inc b/Makefile.inc
index bac0da6..15f5ee5 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -46,6 +46,7 @@ endif
CFLAGS =
LDFLAGS =
DYFLAGS =
+LINT_FLAGS = -weak +posixlib +ignoresigns -fcnuse -badflag -D__gnuc_va_list=va_list -D__attribute\(x\)=
override CFLAGS += -DLCRSODIR='"$(LCRSODIR)"'
diff --git a/exec/Makefile b/exec/Makefile
index 307d5ff..1d138f2 100644
--- a/exec/Makefile
+++ b/exec/Makefile
@@ -137,6 +137,9 @@ liblogsys.so.2.0.0: $(LIBLOGSYS_OBJS)
endif
+lint:
+ -splint $(LINT_FLAGS) $(CFLAGS) *.c
+
clean:
rm -f corosync $(OBJS) *.o *.lcrso libtotem_pg.so* libtotem_pg.a gmon.out
rm -f *.da *.bb *.bbg liblogsys.so* liblogsys.a
diff --git a/exec/apidef.c b/exec/apidef.c
index 7be37a7..240186c 100644
--- a/exec/apidef.c
+++ b/exec/apidef.c
@@ -123,8 +123,6 @@ void apidef_init (struct objdb_iface_ver0 *objdb) {
apidef_corosync_api_v1.object_priv_get = objdb->object_priv_get;
apidef_corosync_api_v1.object_key_replace = objdb->object_key_replace;
apidef_corosync_api_v1.object_key_delete = objdb->object_key_delete;
- apidef_corosync_api_v1.object_iter_reset = objdb->object_iter_reset;
- apidef_corosync_api_v1.object_iter = objdb->object_iter;
apidef_corosync_api_v1.object_key_iter = objdb->object_key_iter;
apidef_corosync_api_v1.object_parent_get = objdb->object_parent_get;
apidef_corosync_api_v1.object_name_get = objdb->object_name_get;
diff --git a/exec/objdb.c b/exec/objdb.c
index b0b60bb..6e5edf7 100644
--- a/exec/objdb.c
+++ b/exec/objdb.c
@@ -90,7 +90,7 @@ struct object_find_instance {
int object_len;
};
-struct objdb_iface_ver0 objdb_iface;
+extern struct objdb_iface_ver0 objdb_iface;
struct list_head objdb_trackers_head;
static pthread_rwlock_t reload_lock;
static pthread_t lock_thread;
@@ -1563,7 +1563,7 @@ struct objdb_iface_ver0 objdb_iface = {
.object_key_decrement = object_key_decrement,
};
-struct lcr_iface objdb_iface_ver0[1] = {
+struct lcr_iface objdb_iface_array_ver0[1] = {
{
.name = "objdb",
.version = 0,
@@ -1579,13 +1579,13 @@ struct lcr_iface objdb_iface_ver0[1] = {
struct lcr_comp objdb_comp_ver0 = {
.iface_count = 1,
- .ifaces = objdb_iface_ver0
+ .ifaces = objdb_iface_array_ver0
};
__attribute__ ((constructor)) static void objdb_comp_register (void) {
- lcr_interfaces_set (&objdb_iface_ver0[0], &objdb_iface);
+ lcr_interfaces_set (&objdb_iface_array_ver0[0], &objdb_iface);
lcr_component_register (&objdb_comp_ver0);
}
diff --git a/exec/totempg.c b/exec/totempg.c
index 89a81aa..4c3862e 100644
--- a/exec/totempg.c
+++ b/exec/totempg.c
@@ -272,7 +272,7 @@ static struct assembly *assembly_ref (unsigned int nodeid)
/*
* TODO handle memory allocation failure here
*/
- assert (assembly);
+ assert (assembly != NULL);
assembly->nodeid = nodeid;
list_init (&assembly->list);
list_add (&assembly->list, &assembly_list_inuse);
@@ -481,7 +481,7 @@ static void totempg_deliver_fn (
int start;
assembly = assembly_ref (nodeid);
- assert (assembly);
+ assert (assembly != NULL);
/*
* Assemble the header into one block of data and
@@ -495,6 +495,7 @@ static void totempg_deliver_fn (
char *data;
int datasize;
+ assert(iovec != NULL);
mcast = (struct totempg_mcast *)iovec[0].iov_base;
if (endian_conversion_required) {
mcast->msg_count = swab16 (mcast->msg_count);
@@ -503,9 +504,10 @@ static void totempg_deliver_fn (
msg_count = mcast->msg_count;
datasize = sizeof (struct totempg_mcast) +
msg_count * sizeof (unsigned short);
-
+
+ assert (datasize < FRAME_SIZE_MAX);
+
memcpy (header, iovec[0].iov_base, datasize);
- assert(iovec);
data = iovec[0].iov_base;
msg_lens = (unsigned short *) (header + sizeof (struct totempg_mcast));
@@ -1243,7 +1245,7 @@ char *totempg_ifaces_print (unsigned int nodeid)
}
for (i = 0; i < iface_count; i++) {
- sprintf (one_iface, "r(%d) ip(%s) ",
+ snprintf (one_iface, 64, "r(%d) ip(%s) ",
i, totemip_print (&interfaces[i]));
strcat (iface_string, one_iface);
}
diff --git a/include/corosync/engine/coroapi.h b/include/corosync/engine/coroapi.h
index f0da9b8..8ee5e2f 100644
--- a/include/corosync/engine/coroapi.h
+++ b/include/corosync/engine/coroapi.h
@@ -255,15 +255,6 @@ struct corosync_api_v1 {
void *value,
int value_len);
- int (*object_iter_reset) (
- unsigned int parent_object_handle);
-
- int (*object_iter) (
- unsigned int parent_object_handle,
- void **object_name,
- int *name_len,
- unsigned int *object_handle);
-
int (*object_key_iter_reset) (
unsigned int object_handle);
diff --git a/include/corosync/engine/objdb.h b/include/corosync/engine/objdb.h
index 507b741..7aea637 100644
--- a/include/corosync/engine/objdb.h
+++ b/include/corosync/engine/objdb.h
@@ -162,15 +162,6 @@ struct objdb_iface_ver0 {
void *value,
int value_len);
- int (*object_iter_reset) (
- unsigned int parent_object_handle);
-
- int (*object_iter) (
- unsigned int parent_object_handle,
- void **object_name,
- int *name_len,
- unsigned int *object_handle);
-
int (*object_key_iter_reset) (
unsigned int object_handle);
diff --git a/lcr/Makefile b/lcr/Makefile
index c263c4b..6d0375e 100755
--- a/lcr/Makefile
+++ b/lcr/Makefile
@@ -84,3 +84,6 @@ clean:
rm -f test libtest.so* *.o uic liblcr.so* liblcr.a *.lcrso *.da *.ba *.bb *.bbg \
test_static
+lint:
+ -splint $(LINT_FLAGS) $(CFLAGS) *.c
+
diff --git a/lib/Makefile b/lib/Makefile
index 5836536..64a1e50 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -121,6 +121,9 @@ clean:
libquorum.so* libquorum.a \
libconfdb.a libconfdb.a \ *.da *.bb *.bbg
+lint:
+ -splint $(LINT_FLAGS) $(CFLAGS) *.c
+
# -fPIC rules required for all libraries
%.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ $<
diff --git a/services/Makefile b/services/Makefile
index 1b323fa..9a586fa 100644
--- a/services/Makefile
+++ b/services/Makefile
@@ -96,6 +96,9 @@ endif
clean:
rm -f *.o *.lcrso
+lint:
+ -splint $(LINT_FLAGS) $(CFLAGS) *.c
+
depend:
makedepend -Y -- $(CFLAGS) $(CPPFLAGS) $(EXEC_SRC) $(TOTEM_SRC) $(LOGSYS_SRC) $(LCR_SRC) > /dev/null 2>&1
diff --git a/tools/Makefile b/tools/Makefile
index ae788a5..82888f3 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -66,6 +66,9 @@ corosync-pload: corosync-pload.o
clean:
rm -f *.o $(BINARIES)
+lint:
+ -splint $(LINT_FLAGS) $(CFLAGS) *.c
+
%.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
--
1.5.6
More information about the Openais
mailing list