summaryrefslogtreecommitdiffstats
path: root/outchannel.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-04-11 17:33:13 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-04-11 17:33:13 +0200
commit890f782323849b2ae01cd705312d54a4a0e348fe (patch)
tree220604babca36e229cc64e9926ff9ebb44f694cd /outchannel.c
parenta7860f4dab1afcf94698bc2f52413e94eed64b52 (diff)
downloadrsyslog-890f782323849b2ae01cd705312d54a4a0e348fe.tar.gz
rsyslog-890f782323849b2ae01cd705312d54a4a0e348fe.tar.xz
rsyslog-890f782323849b2ae01cd705312d54a4a0e348fe.zip
some cleanup
Diffstat (limited to 'outchannel.c')
-rw-r--r--outchannel.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/outchannel.c b/outchannel.c
index 394371f0..d013ea08 100644
--- a/outchannel.c
+++ b/outchannel.c
@@ -91,12 +91,12 @@ static void skip_Comma(char **pp)
/* helper to ochAddLine. Parses a comma-delimited field
* The field is delimited by SP or comma. Leading whitespace
* is "eaten" and does not become part of the field content.
- * returns: 0 - ok, 1 - failure
*/
-static int get_Field(uchar **pp, uchar **pField)
+static rsRetVal get_Field(uchar **pp, uchar **pField)
{
+ DEFiRet;
register uchar *p;
- cstr_t *pStrB;
+ cstr_t *pStrB = NULL;
assert(pp != NULL);
assert(*pp != NULL);
@@ -105,21 +105,25 @@ static int get_Field(uchar **pp, uchar **pField)
skip_Comma((char**)pp);
p = *pp;
- if(rsCStrConstruct(&pStrB) != RS_RET_OK)
- return 1;
+ CHKiRet(rsCStrConstruct(&pStrB));
rsCStrSetAllocIncrement(pStrB, 32);
/* copy the field */
while(*p && *p != ' ' && *p != ',') {
- rsCStrAppendChar(pStrB, *p++);
+ CHKiRet(rsCStrAppendChar(pStrB, *p++));
}
*pp = p;
- rsCStrFinish(pStrB);
- if(rsCStrConvSzStrAndDestruct(pStrB, pField, 0) != RS_RET_OK)
- return 1;
+ CHKiRet(rsCStrFinish(pStrB));
+ CHKiRet(rsCStrConvSzStrAndDestruct(pStrB, pField, 0));
- return 0;
+finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pStrB != NULL)
+ rsCStrDestruct(&pStrB);
+ }
+
+ RETiRet;
}
@@ -156,12 +160,12 @@ static int get_off_t(uchar **pp, off_t *pOff_t)
* current position to the end of line and returns it
* to the caller. Leading white space is removed, but
* not trailing.
- * returns: 0 - ok, 1 - failure
*/
-static inline int get_restOfLine(uchar **pp, uchar **pBuf)
+static inline rsRetVal get_restOfLine(uchar **pp, uchar **pBuf)
{
+ DEFiRet;
register uchar *p;
- cstr_t *pStrB;
+ cstr_t *pStrB = NULL;
assert(pp != NULL);
assert(*pp != NULL);
@@ -170,21 +174,25 @@ static inline int get_restOfLine(uchar **pp, uchar **pBuf)
skip_Comma((char**)pp);
p = *pp;
- if(rsCStrConstruct(&pStrB) != RS_RET_OK)
- return 1;
+ CHKiRet(rsCStrConstruct(&pStrB));
rsCStrSetAllocIncrement(pStrB, 32);
/* copy the field */
while(*p) {
- rsCStrAppendChar(pStrB, *p++);
+ CHKiRet(rsCStrAppendChar(pStrB, *p++));
}
*pp = p;
- rsCStrFinish(pStrB);
- if(rsCStrConvSzStrAndDestruct(pStrB, pBuf, 0) != RS_RET_OK)
- return 1;
+ CHKiRet(rsCStrFinish(pStrB));
+ CHKiRet(rsCStrConvSzStrAndDestruct(pStrB, pBuf, 0));
- return 0;
+finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pStrB != NULL)
+ rsCStrDestruct(&pStrB);
+ }
+
+ RETiRet;
}
@@ -291,6 +299,5 @@ void ochPrintList(void)
pOch = pOch->pNext; /* done, go next */
}
}
-/*
- * vi:set ai:
+/* vi:set ai:
*/