[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36980 - in gnunet/src: include pq
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36980 - in gnunet/src: include pq |
Date: |
Mon, 4 Apr 2016 17:28:43 +0200 |
Author: grothoff
Date: 2016-04-04 17:28:43 +0200 (Mon, 04 Apr 2016)
New Revision: 36980
Modified:
gnunet/src/include/gnunet_pq_lib.h
gnunet/src/pq/pq.c
gnunet/src/pq/pq_result_helper.c
Log:
simplify PQ API by removing NULL as a possible acceptable value
Modified: gnunet/src/include/gnunet_pq_lib.h
===================================================================
--- gnunet/src/include/gnunet_pq_lib.h 2016-04-04 15:06:40 UTC (rev 36979)
+++ gnunet/src/include/gnunet_pq_lib.h 2016-04-04 15:28:43 UTC (rev 36980)
@@ -199,8 +199,7 @@
* @param[out] dst where to store the result
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
- * #GNUNET_SYSERR if a result was invalid (non-existing field)
+ * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
*/
typedef int
(*GNUNET_PQ_ResultConverter)(void *cls,
Modified: gnunet/src/pq/pq.c
===================================================================
--- gnunet/src/pq/pq.c 2016-04-04 15:06:40 UTC (rev 36979)
+++ gnunet/src/pq/pq.c 2016-04-04 15:28:43 UTC (rev 36980)
@@ -151,11 +151,9 @@
&spec->dst_size,
spec->dst);
if (GNUNET_SYSERR == ret)
+ {
+ GNUNET_PQ_cleanup_result (rs);
return GNUNET_SYSERR;
- if (GNUNET_NO == ret)
- {
- had_null = GNUNET_YES;
- continue;
}
if (NULL != spec->result_size)
*spec->result_size = spec->dst_size;
Modified: gnunet/src/pq/pq_result_helper.c
===================================================================
--- gnunet/src/pq/pq_result_helper.c 2016-04-04 15:06:40 UTC (rev 36979)
+++ gnunet/src/pq/pq_result_helper.c 2016-04-04 15:28:43 UTC (rev 36980)
@@ -55,9 +55,8 @@
* @param[out] dst where to store the result
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
* #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ */
static int
extract_varsize_blob (void *cls,
PGresult *result,
@@ -70,7 +69,7 @@
const char *res;
void *idst;
int fnum;
-
+
fnum = PQfnumber (result,
fname);
if (fnum < 0)
@@ -83,8 +82,8 @@
if (PQgetisnull (result,
row,
fnum))
- return GNUNET_NO;
-
+ return GNUNET_SYSERR;
+
/* if a field is null, continue but
* remember that we now return a different result */
len = PQgetlength (result,
@@ -119,7 +118,7 @@
{
struct GNUNET_PQ_ResultSpec res =
{ &extract_varsize_blob,
- &clean_varsize_blob, NULL,
+ &clean_varsize_blob, NULL,
(void *) (dst), 0, name, sptr };
return res;
}
@@ -136,9 +135,8 @@
* @param[out] dst where to store the result
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
- * #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
+ */
static int
extract_fixed_blob (void *cls,
PGresult *result,
@@ -150,7 +148,7 @@
size_t len;
const char *res;
int fnum;
-
+
fnum = PQfnumber (result,
fname);
if (fnum < 0)
@@ -163,14 +161,14 @@
if (PQgetisnull (result,
row,
fnum))
- return GNUNET_NO;
-
+ return GNUNET_SYSERR;
+
/* if a field is null, continue but
* remember that we now return a different result */
len = PQgetlength (result,
row,
fnum);
- if (*dst_size != len)
+ if (*dst_size != len)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Field `%s' has wrong size (got %u, expected %u)\n",
@@ -205,7 +203,7 @@
{
struct GNUNET_PQ_ResultSpec res =
{ &extract_fixed_blob,
- NULL, NULL,
+ NULL, NULL,
(dst), dst_size, name, NULL };
return res;
}
@@ -222,9 +220,8 @@
* @param[out] dst where to store the result
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
- * #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
+ */
static int
extract_rsa_public_key (void *cls,
PGresult *result,
@@ -251,7 +248,7 @@
if (PQgetisnull (result,
row,
fnum))
- return GNUNET_NO;
+ return GNUNET_SYSERR;
/* if a field is null, continue but
* remember that we now return a different result */
@@ -286,7 +283,7 @@
void *rd)
{
struct GNUNET_CRYPTO_RsaPublicKey **pk = rd;
-
+
if (NULL != *pk)
{
GNUNET_CRYPTO_rsa_public_key_free (*pk);
@@ -326,9 +323,8 @@
* @param[out] dst where to store the result
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
- * #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
+ */
static int
extract_rsa_signature (void *cls,
PGresult *result,
@@ -341,7 +337,7 @@
size_t len;
const char *res;
int fnum;
-
+
*sig = NULL;
fnum = PQfnumber (result,
fname);
@@ -355,7 +351,7 @@
if (PQgetisnull (result,
row,
fnum))
- return GNUNET_NO;
+ return GNUNET_SYSERR;
/* if a field is null, continue but
* remember that we now return a different result */
@@ -463,9 +459,8 @@
* @param[out] dst where to store the result
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
- * #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
+ */
static int
extract_uint16 (void *cls,
PGresult *result,
@@ -477,7 +472,7 @@
uint16_t *udst = dst;
const uint16_t *res;
int fnum;
-
+
fnum = PQfnumber (result,
fname);
if (fnum < 0)
@@ -490,7 +485,7 @@
if (PQgetisnull (result,
row,
fnum))
- return GNUNET_NO;
+ return GNUNET_SYSERR;
GNUNET_assert (NULL != dst);
if (sizeof (uint16_t) != *dst_size)
{
@@ -536,9 +531,8 @@
* @param[out] dst where to store the result
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
- * #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
+ */
static int
extract_uint32 (void *cls,
PGresult *result,
@@ -550,7 +544,7 @@
uint32_t *udst = dst;
const uint32_t *res;
int fnum;
-
+
fnum = PQfnumber (result,
fname);
if (fnum < 0)
@@ -563,7 +557,7 @@
if (PQgetisnull (result,
row,
fnum))
- return GNUNET_NO;
+ return GNUNET_SYSERR;
GNUNET_assert (NULL != dst);
if (sizeof (uint32_t) != *dst_size)
{
@@ -590,7 +584,7 @@
uint32_t *u32)
{
struct GNUNET_PQ_ResultSpec res =
- { &extract_uint32,
+ { &extract_uint32,
NULL,
NULL,
(void *) u32, sizeof (*u32), (name), NULL };
@@ -609,9 +603,8 @@
* @param[out] dst where to store the result
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
- * #GNUNET_SYSERR if a result was invalid (non-existing field)
- */
+ * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
+ */
static int
extract_uint64 (void *cls,
PGresult *result,
@@ -623,7 +616,7 @@
uint64_t *udst = dst;
const uint64_t *res;
int fnum;
-
+
fnum = PQfnumber (result,
fname);
if (fnum < 0)
@@ -636,7 +629,7 @@
if (PQgetisnull (result,
row,
fnum))
- return GNUNET_NO;
+ return GNUNET_SYSERR;
GNUNET_assert (NULL != dst);
if (sizeof (uint64_t) != *dst_size)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36980 - in gnunet/src: include pq,
gnunet <=