diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2019-04-12 05:59:39 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2019-04-12 05:59:39 +0530 |
commit | 62ec2bdc6479c6c6bc08fdfdc21825b9e8a989dc (patch) | |
tree | ff4d466fff11457687f3be9edf9c39326723c1b0 | |
parent | 917606eea71e279ee82c53ea8a22ce3e18978ceb (diff) |
Merge latest changescoverity_scan
-rw-r--r-- | src/bcal.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -70,7 +70,7 @@ typedef struct { uchar loglvl : 2; } settings; -static char *VERSION = "2.0"; +static char *VERSION = "2.1"; static char *units[] = {"b", "kib", "mib", "gib", "tib", "kb", "mb", "gb", "tb"}; static char *logarr[] = {"ERROR", "WARNING", "INFO", "DEBUG"}; @@ -205,7 +205,7 @@ static int try_bc(char *expr) dup2(pipe_cp[1], STDOUT_FILENO); // Give stdout to parent dup2(pipe_cp[1], STDERR_FILENO); // Give stderr to parent - ret = execlp("bc", "bc", "-q", (char*) NULL); + ret = execlp("bc", "bc", (char*) NULL); log(ERROR, "execlp() failed!\n"); exit(ret); } @@ -216,6 +216,7 @@ static int try_bc(char *expr) exit(-1); } +#ifdef __GNU_LIBRARY__ if (write(pipe_pc[1], "last=", 5) != 5) { log(ERROR, "write(2)! [%s]\n", strerror(errno)); exit(-1); @@ -238,6 +239,7 @@ static int try_bc(char *expr) log(ERROR, "write(5)! [%s]\n", strerror(errno)); exit(-1); } +#endif ret = strlen(expr); if (write(pipe_pc[1], expr, ret) != ret) { @@ -1155,7 +1157,7 @@ optional arguments:\n\ prompt_help(); printf("\nVersion %s\n\ -Copyright © 2016-2018 Arun Prakash Jana <engineerarun@gmail.com>\n\ +Copyright © 2016 Arun Prakash Jana <engineerarun@gmail.com>\n\ License: GPLv3\n\ Webpage: https://github.com/jarun/bcal\n", VERSION); } @@ -1923,7 +1925,8 @@ static int evaluate(char *exp, ulong sectorsz) char *expr = fixexpr(exp, &ret); /* Make parsing compatible */ char *ptr; - log(DEBUG, "expr: %s\n", expr); + if (expr) + log(DEBUG, "expr: %s\n", expr); if (expr == NULL) { if (ret) @@ -2137,7 +2140,11 @@ int main(int argc, char **argv) case 'b': cfg.bcmode ^= 1; if (cfg.bcmode) { +#ifdef __GNU_LIBRARY__ printf("bc vars: scale = 10, ibase = 10, last = r\n"); +#else + printf("bc vars: scale = 10, ibase = 10, last = 0\n"); +#endif strncpy(prompt, "bc> ", 5); } else strncpy(prompt, "bcal> ", 7); |