respect getcwd return value
authorMatthias Braun <matthias.braun@kit.edu>
Fri, 13 Jul 2012 21:09:08 +0000 (23:09 +0200)
committerMatthias Braun <matthias.braun@kit.edu>
Mon, 16 Jul 2012 14:49:51 +0000 (16:49 +0200)
this fixes a warning

ast2firm.c

index b366350..4c609f4 100644 (file)
@@ -5581,8 +5581,9 @@ static void global_asm_to_firm(statement_t *s)
 static const char *get_cwd(void)
 {
        static char buf[1024];
-       if (buf[0] == '\0')
-               getcwd(buf, sizeof(buf));
+       if (buf[0] == '\0') {
+               return getcwd(buf, sizeof(buf));
+       }
        return buf;
 }
 
@@ -5597,7 +5598,10 @@ void translation_unit_to_firm(translation_unit_t *unit)
        } else {
                be_dwarf_set_source_language(DW_LANG_C);
        }
-       be_dwarf_set_compilation_directory(get_cwd());
+       const char *cwd = get_cwd();
+       if (cwd != NULL) {
+               be_dwarf_set_compilation_directory(cwd);
+       }
 
        /* initialize firm arithmetic */
        tarval_set_integer_overflow_mode(TV_OVERFLOW_WRAP);