Message ID | 1538712196-13625-16-git-send-email-sandeen@sandeen.net (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | xfsprogs: sparse fixes | expand |
While the scope change is a good start the code is stull horrible. I'd be much happier to kill these static variables entirely. The buffers can just be on stack, and getprent should just get a fs_project_t to fill out passed by reference. Same for getprpathent.
On 10/6/18 5:18 AM, Christoph Hellwig wrote: > While the scope change is a good start the code is stull horrible. > > I'd be much happier to kill these static variables entirely. The > buffers can just be on stack, and getprent should just get a > fs_project_t to fill out passed by reference. Same for > getprpathent. > I had assumed that the goal was to behave just like getpwent, which is a void function and does not require a struct passwd to be passed in (for example). The symmetry of use made sense to me. -Eric
diff --git a/libfrog/projects.c b/libfrog/projects.c index d4dda3f..91bc78f 100644 --- a/libfrog/projects.c +++ b/libfrog/projects.c @@ -15,12 +15,8 @@ char *projid_file; char *projects_file; static FILE *projects; -static fs_project_t p; -static char projects_buffer[512]; static FILE *project_paths; -static fs_project_path_t pp; -static char project_paths_buffer[1024]; void setprfiles(void) @@ -64,8 +60,10 @@ endprpathent(void) fs_project_t * getprent(void) { - char *idstart, *idend; - size_t size = sizeof(projects_buffer) - 1; + static fs_project_t p; + static char projects_buffer[512]; + char *idstart, *idend; + size_t size = sizeof(projects_buffer) - 1; if (!projects) return NULL; @@ -125,6 +123,8 @@ getprprid( fs_project_path_t * getprpathent(void) { + static fs_project_path_t pp; + static char project_paths_buffer[1024]; char *nmstart, *nmend; size_t size = sizeof(project_paths_buffer) - 1;