Skip to content

Commit

Permalink
avoid a few GCC6 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wojdyr committed Aug 12, 2016
1 parent 445735f commit 8ed7fd5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
6 changes: 5 additions & 1 deletion cli/gnuplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ void GnuPlot::fork_and_make_pipe()
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
int fd[2];
pipe(fd);
int ret = pipe(fd);
if (ret == -1) {
perror("pipe");
exit(1);
}
pid_t childpid = fork();
if (childpid == -1) {
perror("fork");
Expand Down
8 changes: 4 additions & 4 deletions fityk/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,10 @@ void get_factors(OpTree *a, OpTree *expo,
found = true;
break;
}
if (!found) {
v.push_back(MultFactor(a, expo->clone()));
return; //don't delete a
}
if (!found) {
v.push_back(MultFactor(a, expo->clone()));
return; //don't delete a
}
}
//we are here -- MultFactor(a,...) not created
a->c1 = a->c2 = 0;
Expand Down
4 changes: 2 additions & 2 deletions fityk/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ bool is_fityk_script(string filename)

const int magic_len = strlen(magic);
char buffer[32];
fgets(buffer, magic_len, f);
char *ret = fgets(buffer, magic_len, f);
fclose(f);
return !strncmp(magic, buffer, magic_len);
return ret && !strncmp(magic, buffer, magic_len);
}

void Full::process_cmd_line_arg(const string& arg)
Expand Down
4 changes: 2 additions & 2 deletions fityk/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ string simple_user_input(const string& prompt)
printf("%s ", prompt.c_str());
fflush(stdout);
char s[100];
fgets(s, 100, stdin);
return strip_string(s);
char *ret = fgets(s, 100, stdin);
return ret ? strip_string(s) : "";
}

UiApi::UiApi()
Expand Down
14 changes: 9 additions & 5 deletions wxgui/ceria.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,9 @@ CelFile read_cel_file(FILE *f)
return cel;
}
while (1) {
fscanf(f, "%12s", s);
r = fscanf(f, "%12s", s);
if (r != 1)
return cel;
if (strcmp(s, "RGNR") == 0 || strcmp(s, "rgnr") == 0
|| strcmp(s, "Rgnr") == 0)
break;
Expand All @@ -757,14 +759,16 @@ CelFile read_cel_file(FILE *f)
cel.sgs = find_first_sg_with_number(sgn);
for (int c = fgetc(f); c != '\n' && c != EOF; c = fgetc(f)) {
if (c == ':') {
fscanf(f, "%8s", s);
cel.sgs = find_space_group_setting(sgn, s);
r = fscanf(f, "%8s", s);
if (r == 1)
cel.sgs = find_space_group_setting(sgn, s);
break;
} else if (isdigit(c)) {
ungetc(c, f);
int pc_setting;
fscanf(f, "%d", &pc_setting);
cel.sgs = get_sg_from_powdercell_rgnr(sgn, pc_setting);
r = fscanf(f, "%d", &pc_setting);
if (r == 1)
cel.sgs = get_sg_from_powdercell_rgnr(sgn, pc_setting);
break;
} else if (!isspace(c))
break;
Expand Down
4 changes: 2 additions & 2 deletions wxgui/textpane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ TextPane::TextPane(wxWindow *parent)
FILE *f = wxFopen(hist_file, "r");
if (f) {
char buf[10];
fgets(buf, 10, f);
char* ret = fgets(buf, 10, f);
fclose(f);
if (strncmp(buf, "_HiStOrY_", 9) == 0) // libedit weirdness
if (ret && strncmp(buf, "_HiStOrY_", 9) == 0) // libedit weirdness
hist_file += "_gui";
}
input_field = new InputLine(this, -1, this, hist_file);
Expand Down

0 comments on commit 8ed7fd5

Please sign in to comment.