poldek: tndb/Makefile.am, tndb/configure.in, tndb/read.c, tndb/tnd...
mis
mis at pld-linux.org
Fri Jun 22 14:51:52 CEST 2007
Author: mis Date: Fri Jun 22 12:51:52 2007 GMT
Module: poldek Tag: HEAD
---- Log message:
- killed some signedness warnings; tests/
---- Files affected:
poldek/tndb:
Makefile.am (1.4 -> 1.5) , configure.in (1.5 -> 1.6) , read.c (1.12 -> 1.13) , tndb.c (1.12 -> 1.13) , tndb_dump.c (1.1.1.1 -> 1.2) , tndb_int.h (1.7 -> 1.8) , write.c (1.9 -> 1.10)
---- Diffs:
================================================================
Index: poldek/tndb/Makefile.am
diff -u poldek/tndb/Makefile.am:1.4 poldek/tndb/Makefile.am:1.5
--- poldek/tndb/Makefile.am:1.4 Fri May 13 18:29:32 2005
+++ poldek/tndb/Makefile.am Fri Jun 22 14:51:47 2007
@@ -19,6 +19,8 @@
test_tndb_LDADD = libtndb.la
tndb_dump_LDADD = $(test_tndb_LDADD)
+DIST_SUBDIRS = tests
+
MAINTAINERCLEANFILES = mkinstalldirs install-sh missing *.tar.gz *.spec \
config.h.in configure Makefile.in config.h \
config.sub config.guess config.status config.log aclocal.m4 \
@@ -29,8 +31,6 @@
#symlink:
# @if [ ! -d tndb ]; then ln . tndb -s; fi;
-
-tests: $(EXTRA_PROGRAMS)
all-local:
@ln -sf .libs/libtndb.a libtndb.a
================================================================
Index: poldek/tndb/configure.in
diff -u poldek/tndb/configure.in:1.5 poldek/tndb/configure.in:1.6
--- poldek/tndb/configure.in:1.5 Sat Nov 25 20:40:52 2006
+++ poldek/tndb/configure.in Fri Jun 22 14:51:47 2007
@@ -23,6 +23,8 @@
AC_C_CONST
AC_TYPE_SIZE_T
+PKG_CHECK_MODULES(CHECK, check >= 0.9.4, have_check=yes, have_check=no)
+
dnl Checks for library functions.
AC_CHECK_FUNCS(mkstemp)
@@ -46,4 +48,6 @@
AC_CHECK_LIB(trurl, n_cfree)
fi
-AC_OUTPUT([ Makefile ])
+
+AC_CONFIG_FILES([ Makefile tests/Makefile ])
+AC_OUTPUT
================================================================
Index: poldek/tndb/read.c
diff -u poldek/tndb/read.c:1.12 poldek/tndb/read.c:1.13
--- poldek/tndb/read.c:1.12 Tue Jan 24 21:37:52 2006
+++ poldek/tndb/read.c Fri Jun 22 14:51:47 2007
@@ -49,11 +49,11 @@
static
-int md5(FILE *stream, unsigned char *md, int *md_size)
+int md5(FILE *stream, unsigned char *md, unsigned *md_size)
{
unsigned char buf[8*1024];
EVP_MD_CTX ctx;
- int n, nn = 0;
+ unsigned n, nn = 0;
n_assert(md_size && *md_size);
@@ -79,17 +79,17 @@
}
static
-int md5hex(FILE *stream, unsigned char *mdhex, int *mdhex_size)
+int md5hex(FILE *stream, unsigned char *mdhex, unsigned *mdhex_size)
{
unsigned char md[128];
- int md_size = sizeof(md);
+ unsigned md_size = sizeof(md);
if (md5(stream, md, &md_size)) {
int i, n = 0, nn = 0;
- for (i=0; i < md_size; i++) {
- n = n_snprintf(mdhex + nn, *mdhex_size - nn, "%02x", md[i]);
+ for (i=0; i < (int)md_size; i++) {
+ n = n_snprintf((char*)mdhex + nn, *mdhex_size - nn, "%02x", md[i]);
nn += n;
}
*mdhex_size = nn;
@@ -111,8 +111,7 @@
FILE *stream;
unsigned char md[128];
char path[PATH_MAX];
- int md_size = sizeof(md);
-
+ unsigned md_size = sizeof(md);
if ((stream = fopen(pathname, "r")) == NULL)
return 0;
@@ -139,8 +138,9 @@
{
FILE *stream;
unsigned char md1[DIGEST_SIZE_MD5 + 1], md2[DIGEST_SIZE_MD5 + 1];
- int fd, md1_size, md2_size;
+ unsigned md1_size, md2_size;
char path[PATH_MAX];
+ int fd;
snprintf(path, sizeof(path), "%s.md5", pathname);
if ((fd = open(path, O_RDONLY)) < 0)
@@ -510,10 +510,12 @@
{
struct tndb_it it;
char key[TNDB_KEY_MAX + 1];
- int klen, vlen, rc;
+ unsigned klen, vlen;
tn_array *keys;
off_t voffs;
+ int rc;
+
if (!verify_db(db))
return NULL;
================================================================
Index: poldek/tndb/tndb.c
diff -u poldek/tndb/tndb.c:1.12 poldek/tndb/tndb.c:1.13
--- poldek/tndb/tndb.c:1.12 Sun Aug 20 16:07:19 2006
+++ poldek/tndb/tndb.c Fri Jun 22 14:51:47 2007
@@ -23,6 +23,7 @@
#include <openssl/evp.h>
+#include <trurl/n_snprintf.h>
#include <trurl/nassert.h>
#include <trurl/nmalloc.h>
#include <trurl/n2h.h>
@@ -111,7 +112,7 @@
void tndb_sign_final(struct tndb_sign *sign)
{
unsigned char buf[1024];
- int n;
+ unsigned n;
//printf("%p %p >> FINAL\n", sign, sign->ctx);
EVP_DigestFinal(sign->ctx, buf, &n);
@@ -282,8 +283,8 @@
memset(hdr, 0, sizeof(*hdr));
hdr->flags |= flags;
- snprintf(hdr->hdr, sizeof(hdr->hdr), "tndb%d.%d\n",
- TNDB_FILEFMT_MAJOR, TNDB_FILEFMT_MINOR);
+ n_snprintf((char*)hdr->hdr, sizeof(hdr->hdr), "tndb%d.%d\n",
+ TNDB_FILEFMT_MAJOR, TNDB_FILEFMT_MINOR);
if (flags & TNDB_SIGN_DIGEST)
tndb_sign_init(&hdr->sign);
================================================================
Index: poldek/tndb/tndb_dump.c
diff -u poldek/tndb/tndb_dump.c:1.1.1.1 poldek/tndb/tndb_dump.c:1.2
--- poldek/tndb/tndb_dump.c:1.1.1.1 Wed Nov 13 00:54:21 2002
+++ poldek/tndb/tndb_dump.c Fri Jun 22 14:51:47 2007
@@ -73,7 +73,7 @@
return -1;
}
- printf("%s\n", key);
+ printf("KEY = %s\n", key);
if (flags & DUMP_DATA) {
unsigned char *buf, *p;
int i;
@@ -90,7 +90,7 @@
if (!isprint(buf[i]))
buf[i] = '.';
- printf("%s\n\n", buf);
+ printf("DATA = %s\n\n--------------------------------------------------\n", buf);
}
}
return 0;
================================================================
Index: poldek/tndb/tndb_int.h
diff -u poldek/tndb/tndb_int.h:1.7 poldek/tndb/tndb_int.h:1.8
--- poldek/tndb/tndb_int.h:1.7 Sun Nov 6 20:33:10 2005
+++ poldek/tndb/tndb_int.h Fri Jun 22 14:51:47 2007
@@ -63,12 +63,10 @@
tndb_sign_update(hdr->sign, buf, size); \
} while(0);
-
-
-
+/* hash entry */
struct tndb_hent {
- uint32_t val;
- uint32_t offs;
+ uint32_t val; /* hashed key */
+ uint32_t offs; /* offset in file */
};
struct tndb;
@@ -144,9 +142,6 @@
# define DBGF(fmt, args...) ((void) 0)
# define DBG(fmt, args...) ((void) 0)
#endif
-
-#define DBGMSG_F DBGF
-#define DBGMSG DBG
#define DBGF_NULL(fmt, args...) ((void) 0)
#define DBGF_F(fmt, args...) fprintf(stdout, "%-18s: " fmt, __FUNCTION__ , ## args)
================================================================
Index: poldek/tndb/write.c
diff -u poldek/tndb/write.c:1.9 poldek/tndb/write.c:1.10
--- poldek/tndb/write.c:1.9 Tue Jan 24 21:37:52 2006
+++ poldek/tndb/write.c Fri Jun 22 14:51:47 2007
@@ -61,7 +61,7 @@
return NULL;
rmdir(path);
- unlink(path);
+ unlink(path); /* unlink just after create, it's temporary file */
n = strlen(name);
if (n > 3 && strcmp(&name[n - 3], ".gz") == 0) {
@@ -246,7 +246,8 @@
return 1;
}
-static int htt_compute(struct tndb *db)
+/* computes and writes htt's digest */
+static int htt_compute_digest(struct tndb *db)
{
int rc;
@@ -275,7 +276,7 @@
n_stream_close(db->st);
db->st = NULL;
- if ((fdout = open(db->path, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1)
+ if ((fdout = open(db->path, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1)
goto l_end;
if ((db->st = n_stream_dopen(fdout, "wb", type)) == NULL)
@@ -288,7 +289,7 @@
tndb_hdr_compute_digest(&db->hdr);
if ((db->hdr.flags & TNDB_NOHASH) == 0)
- if (!htt_compute(db))
+ if (!htt_compute_digest(db))
goto l_end;
================================================================
---- CVS-web:
http://cvs.pld-linux.org/poldek/tndb/Makefile.am?r1=1.4&r2=1.5&f=u
http://cvs.pld-linux.org/poldek/tndb/configure.in?r1=1.5&r2=1.6&f=u
http://cvs.pld-linux.org/poldek/tndb/read.c?r1=1.12&r2=1.13&f=u
http://cvs.pld-linux.org/poldek/tndb/tndb.c?r1=1.12&r2=1.13&f=u
http://cvs.pld-linux.org/poldek/tndb/tndb_dump.c?r1=1.1.1.1&r2=1.2&f=u
http://cvs.pld-linux.org/poldek/tndb/tndb_int.h?r1=1.7&r2=1.8&f=u
http://cvs.pld-linux.org/poldek/tndb/write.c?r1=1.9&r2=1.10&f=u
More information about the pld-cvs-commit
mailing list