Have radmsg_copy_attrs() return error in all error cases.
authorLinus Nordberg <linus@nordberg.se>
Wed, 28 Aug 2013 11:48:49 +0000 (13:48 +0200)
committerLinus Nordberg <linus@nordberg.se>
Fri, 6 Sep 2013 13:16:41 +0000 (15:16 +0200)
Also when copying of the first attribute fails.

radmsg.c

index 6e33990..7f6dd9d 100644 (file)
--- a/radmsg.c
+++ b/radmsg.c
@@ -106,9 +106,7 @@ struct tlv *radmsg_gettype(struct radmsg *msg, uint8_t type) {
  * If all attributes were copied successfully, the number of
  * attributes copied is returned.
  *
- * If copying failed, a negative number is returned. The number
- * returned is 0 minus the number of attributes successfully copied
- * before the failure. */
+ * If copying failed, a negative number is returned. */
 int radmsg_copy_attrs(struct radmsg *dst,
                       const struct radmsg *src,
                       uint8_t type)
@@ -119,7 +117,7 @@ int radmsg_copy_attrs(struct radmsg *dst,
 
     for (node = list_first(list); node; node = list_next(node)) {
         if (radmsg_add(dst, copytlv((struct tlv *) node->data)) != 1) {
-            n = -n;
+            n = -1;
             break;
         }
         n++;