Skip to content

Comments

Use HOME directory for the WDSP wisdom file#197

Open
yarda wants to merge 1 commit intog0orx:masterfrom
yarda:wdsp-in-home-dir
Open

Use HOME directory for the WDSP wisdom file#197
yarda wants to merge 1 commit intog0orx:masterfrom
yarda:wdsp-in-home-dir

Conversation

@yarda
Copy link

@yarda yarda commented Nov 6, 2024

No description provided.

main.c Outdated
char *c=getcwd(wisdom_directory, sizeof(wisdom_directory));
char *c=getenv("HOME");
if (c) {
strncpy(wisdom_directory, c, 1023);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use sizeof(wisdom_directory)-1 for size.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants