Use coccinelle to cleanup the failure handling blocks from isc_mem_strdup

This commit is contained in:
Ondřej Surý
2019-07-23 11:12:11 -04:00
parent 601cb4e4cc
commit 9bdc24a9fd
37 changed files with 10 additions and 269 deletions

View File

@@ -1196,10 +1196,6 @@ isc_httpdmgr_addurl2(isc_httpdmgr_t *httpdmgr, const char *url,
item = isc_mem_get(httpdmgr->mctx, sizeof(isc_httpdurl_t));
item->url = isc_mem_strdup(httpdmgr->mctx, url);
if (item->url == NULL) {
isc_mem_put(httpdmgr->mctx, item, sizeof(isc_httpdurl_t));
return (ISC_R_NOMEMORY);
}
item->action = func;
item->action_arg = arg;

View File

@@ -191,10 +191,6 @@ new_source(isc_lex_t *lex, bool is_file, bool need_close,
source->last_was_eol = lex->last_was_eol;
source->input = input;
source->name = isc_mem_strdup(lex->mctx, name);
if (source->name == NULL) {
isc_mem_put(lex->mctx, source, sizeof(*source));
return (ISC_R_NOMEMORY);
}
source->pushback = NULL;
result = isc_buffer_allocate(lex->mctx, &source->pushback,
(unsigned int)lex->max_token);
@@ -1000,8 +996,6 @@ isc_lex_setsourcename(isc_lex_t *lex, const char *name) {
if (source == NULL)
return (ISC_R_NOTFOUND);
newname = isc_mem_strdup(lex->mctx, name);
if (newname == NULL)
return (ISC_R_NOMEMORY);
isc_mem_free(lex->mctx, source->name);
source->name = newname;
return (ISC_R_SUCCESS);

View File

@@ -702,10 +702,6 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name,
channel = isc_mem_get(mctx, sizeof(*channel));
channel->name = isc_mem_strdup(mctx, name);
if (channel->name == NULL) {
isc_mem_put(mctx, channel, sizeof(*channel));
return (ISC_R_NOMEMORY);
}
channel->type = type;
channel->level = level;
@@ -723,8 +719,8 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name,
* to scribble on it, so it needs to be definitely in
* writable memory.
*/
FILE_NAME(channel) =
isc_mem_strdup(mctx, destination->file.name);
FILE_NAME(channel) = isc_mem_strdup(mctx,
destination->file.name);
FILE_STREAM(channel) = NULL;
FILE_VERSIONS(channel) = destination->file.versions;
FILE_SUFFIX(channel) = destination->file.suffix;
@@ -920,8 +916,6 @@ isc_log_settag(isc_logconfig_t *lcfg, const char *tag) {
if (lcfg->tag != NULL)
isc_mem_free(lcfg->lctx->mctx, lcfg->tag);
lcfg->tag = isc_mem_strdup(lcfg->lctx->mctx, tag);
if (lcfg->tag == NULL)
return (ISC_R_NOMEMORY);
} else {
if (lcfg->tag != NULL)