naelstrof/maim — pull request #4 by mrshu (2014-10-16 07:23:22+00:00)
Title: update: Fixed compile warning regarding getcwd

* Used MAXPATHLEN to avoid issues with buffer size for current working
directory
* Handled the return value of `getcwd` which previously caused a
compile-time warning.

Signed-off-by: mr.Shu

------------ >8 ------------

This should help with the FIXME you've left in the code. I've ran into this while installing maim:

```
g++ -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -c -o main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:108:34: warning: ignoring return value of ‘char* getcwd(char*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
getcwd( currentdir, 512 );
^
```

This should presumably fix it.

Also please note that the inclusion of `` is necessary for `MAXPATHLEN` and similarly `` is necessary for `errno`.

Regarding that FIXME comment: in my view this is as safe as it gets. You would need some C++ framework to use a real C++ equivalent.