Skip to content
Snippets Groups Projects
Commit 6f1520b3 authored by ericrw96's avatar ericrw96
Browse files

Merge branch 'fix-unchecked-return' into 'master'

Fix unchecked return value to prevent VSCode compiler errors

This error was reported by a student, who noticed when compiling in VSCode, the following error message was generated:

```
threadpool_lib.c: In function 'count_number_of_threads':
threadpool_lib.c:46:9 error: ignoring return value of 'fgets', declared with attribute warn_unused_result [-Werror=unused-result]
    fgets(buf, sizeof buf, p);
    ^
cc1: all warnings treated as errors
<builtin>: recipe for target 'threadpool_lib.o' failed
make: *** [threadpool_lib.o] Error 1
```

I was not able to reproduce this problem in `clang` or `gcc` on my machine, but I figured it was worth the PR. We should be checking return values anyways.

See merge request !4
parents b525e5b9 ec689947
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,8 @@ count_number_of_threads(void)
while (!feof(p)) {
int threadsleft;
char buf[128];
fgets(buf, sizeof buf, p);
if (fgets(buf, sizeof buf, p) == NULL)
continue;
if (sscanf(buf, "Threads: %d\n", &threadsleft) != 1)
continue;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment