From: <svn...@op...> - 2009-02-25 15:24:35
|
Author: bellmich Date: Wed Feb 25 16:24:29 2009 New Revision: 953 URL: http://libsyncml.opensync.org/changeset/953 Log: If goto is used then this use should be reduced to one label. Modified: trunk/libsyncml/sml_notification.c Modified: trunk/libsyncml/sml_notification.c ============================================================================== --- trunk/libsyncml/sml_notification.c Wed Feb 25 16:23:18 2009 (r952) +++ trunk/libsyncml/sml_notification.c Wed Feb 25 16:24:29 2009 (r953) @@ -334,32 +334,35 @@ */ smlAssert(san->manager); + SmlAssembler *assm = NULL; + SmlLocation *source = NULL; + SmlSession *session = NULL; SmlSanAlert *alert = NULL; SmlCommand *cmd = NULL; - SmlAssembler *assm = smlAssemblerNew(san->type, 0, error); - if (!assm) - goto error; - - SmlLocation *source = smlLocationNew(san->identifier, NULL, error); + source = smlLocationNew(san->identifier, NULL, error); if (!source) - goto error_free_assm; + goto error; char *sessionString = smlManagerGetNewSessionID(san->manager); - SmlSession *session = smlSessionNew(san->sessionType, san->type, version, SML_PROTOCOL_SYNCML, san->target, source, sessionString, 0, error); + session = smlSessionNew(san->sessionType, san->type, version, SML_PROTOCOL_SYNCML, san->target, source, sessionString, 0, error); if (!session) { smlSafeCFree(&sessionString); smlLocationUnref(source); - goto error_free_assm; + goto error; } smlSafeCFree(&sessionString); smlManagerSessionAdd(san->manager, session, NULL, error); + assm = smlAssemblerNew(san->type, 0, error); + if (!assm) + goto error; + if (!smlAssemblerStart(assm, session, error)) - goto error_free_session; + goto error; if (!smlAssemblerAddHeader(assm, session, error)) - goto error_free_session; + goto error; GList *a = NULL; int i = 1; @@ -369,22 +372,22 @@ SmlLocation *loc = smlLocationNew(alert->serverURI, NULL, error); if (!loc) - goto error_free_session; + goto error; cmd = smlCommandNewAlert(SML_ALERT_TWO_WAY_BY_SERVER, NULL, loc, NULL, NULL, alert->contenttype, error); if (!cmd) { smlLocationUnref(loc); - goto error_free_session; + goto error; } cmd->cmdID = i; i++; if (!smlAssemblerStartCommand(assm, NULL, cmd, error) == SML_ASSEMBLER_RESULT_OK) - goto error_free_cmd; + goto error; if (!smlAssemblerEndCommand(assm, NULL, error)) - goto error_free_cmd; + goto error; smlLocationUnref(loc); @@ -392,7 +395,7 @@ } if (!smlAssemblerRun(assm, data, size, NULL, TRUE, error)) - goto error_free_session; + goto error; smlAssemblerFlush(assm); @@ -409,13 +412,13 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; -error_free_cmd: - smlCommandUnref(cmd); -error_free_session: - smlSessionUnref(session); -error_free_assm: - smlAssemblerFree(assm); error: + if (cmd) + smlCommandUnref(cmd); + if (session) + smlSessionUnref(session); + if (assm) + smlAssemblerFree(assm); *data = NULL; *size = 0; smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); @@ -428,6 +431,7 @@ CHECK_ERROR_REF smlAssert(san); smlAssert(data); + smlAssert(*data == NULL); smlAssert(size); unsigned int numsync = 0; SmlSanAlert *alert = NULL; @@ -563,9 +567,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; -error_free_data: - smlSafeCFree(data); error: + if (*data) + smlSafeCFree(data); *size = 0; smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); return FALSE; |