From 606095f2fe955f61aea88cd2e7ed9a6387eecaac Mon Sep 17 00:00:00 2001 From: Tatsuhiko Kubo Date: Thu, 1 Jan 2015 05:12:41 +0900 Subject: Remove redundant NULL checks for mrb_malloc(). --- mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c | 26 ++++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c') diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c b/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c index 734f03f0a..999bd6328 100755 --- a/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c +++ b/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c @@ -48,15 +48,15 @@ build_path(mrb_state *mrb, const char *dir, const char *base) len += strlen(dir) + strlen("/"); } - if ((path = mrb_malloc(mrb, len)) != NULL) { - memset(path, 0, len); + path = mrb_malloc(mrb, len); + memset(path, 0, len); - if (strcmp(dir, ".")) { - strcat(path, dir); - strcat(path, "/"); - } - strcat(path, base); + if (strcmp(dir, ".")) { + strcat(path, dir); + strcat(path, "/"); } + strcat(path, base); + return path; } @@ -73,10 +73,10 @@ dirname(mrb_state *mrb, const char *path) p = strrchr(path, '/'); len = p != NULL ? p - path : strlen(path); - if ((dir = mrb_malloc(mrb, len + 1)) != NULL) { - strncpy(dir, path, len); - dir[len] = '\0'; - } + dir = mrb_malloc(mrb, len + 1); + strncpy(dir, path, len); + dir[len] = '\0'; + return dir; } @@ -85,9 +85,7 @@ source_file_new(mrb_state *mrb, mrb_debug_context *dbg, char *filename) { source_file *file = NULL; - if ((file = mrb_malloc(mrb, sizeof(source_file))) == NULL) { - return NULL; - } + file = mrb_malloc(mrb, sizeof(source_file)); memset(file, '\0', sizeof(source_file)); file->fp = fopen(filename, "rb"); -- cgit v1.2.3