Use HOME directory for the WDSP wisdom file#197
Conversation
main.c
Outdated
| char *c=getcwd(wisdom_directory, sizeof(wisdom_directory)); | ||
| char *c=getenv("HOME"); | ||
| if (c) { | ||
| strncpy(wisdom_directory, c, 1023); |
There was a problem hiding this comment.
I would use sizeof(wisdom_directory)-1 for size.
There was a problem hiding this comment.
Wouldn't be something like ~/.local/state/pihpsdr directory more appropriate? I am not sure what exactly that wisdom file is for, but storing it directly in $HOME does not seem correct in any case. At least ~/.pihpsdr would be expected by me.
There was a problem hiding this comment.
sizeof() is better, I will update it.
Subdirectory would require directory creation and error handling, i.e. more code. Moreover, IMHO the wisdom file can be shared across any application using WDSP library. Putting it into HOME prevents the application from recalculation of it when starting from different directories. Recalculation can take a lot of time. I don't know whether it can be calculated on the builder (there could be utilized target CPU optimizations, but I am not sure about it) and put e.g. to /var, but these are bigger changes that should be handled by WDSP upstream.
There was a problem hiding this comment.
If the same recalculation can be used also by other applications, then we have ~/.local/share/wdsp for example. Sure, I am aware it might need to create directories first, making the code more complicated. Ideally https://specifications.freedesktop.org/basedir-spec/latest/#variables should be used, with a nice default if undefined. I do not think putting garbage into $HOME directly is the correct way, even when it is simpler.
main.c
Outdated
| else { | ||
| getcwd(wisdom_directory, sizeof(wisdom_directory)); | ||
| } | ||
| wisdom_directory[1023]=0; |
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
e51af8e to
b896a79
Compare
No description provided.