From d40369b0e09e4e2228ebff305067ec2d99220848 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sun, 14 Jan 2018 18:28:35 -0600 Subject: global: Format the code consistently * Apply clang-format. * Change all comments to the same style. * Add braces as dictated by the coding style guidelines. Signed-off-by: Samuel Holland --- libgcompat/resource.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'libgcompat/resource.c') diff --git a/libgcompat/resource.c b/libgcompat/resource.c index 029b31e..4a7ab4e 100644 --- a/libgcompat/resource.c +++ b/libgcompat/resource.c @@ -1,8 +1,8 @@ -#include /* setrlimit, struct rlimit */ -#include /* assert */ -#include /* dlsym, RTLD_NEXT */ -#include /* NULL */ -#include /* memcpy */ +#include /* assert */ +#include /* dlsym, RTLD_NEXT */ +#include /* NULL */ +#include /* memcpy */ +#include /* setrlimit, struct rlimit */ /* Sigh. * Valve compiled Steam against the glibc2.2 version of setrlimit. @@ -11,7 +11,7 @@ * So, what you have to do is: if you want to run steam with this gcompat, * ensure you compile *without* defining NO_BROKEN_SHADOW_SETRLIMIT. * If you do *not* want to run steam with this gcompat, define it. - * + * * The only problem with enabling this all the time is that if a binary * really does need a ulimit to be 0 for any reason (such as coredumps), it * very obviously won't work here. @@ -27,8 +27,7 @@ int setrlimit(int resource, const struct rlimit *rlim) memcpy(&my_rlim, rlim, sizeof(struct rlimit)); - if(my_rlim.rlim_cur == 0) - { + if (my_rlim.rlim_cur == 0) { my_rlim.rlim_cur = my_rlim.rlim_max; } -- cgit v1.2.3-60-g2f50 From c735fc99ec9e96520da0ea938890eed8fe64b50e Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sun, 14 Jan 2018 22:27:11 -0600 Subject: resource: Minor improvements * Make function pointer static. * Only initialize function pointer once. Signed-off-by: Samuel Holland --- libgcompat/resource.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libgcompat/resource.c') diff --git a/libgcompat/resource.c b/libgcompat/resource.c index 4a7ab4e..836d5e2 100644 --- a/libgcompat/resource.c +++ b/libgcompat/resource.c @@ -17,16 +17,17 @@ * very obviously won't work here. */ #ifndef NO_BROKEN_SHADOW_SETRLIMIT -int (*real_rlimit)(int, const struct rlimit *); +static int (*real_rlimit)(int, const struct rlimit *); int setrlimit(int resource, const struct rlimit *rlim) { struct rlimit my_rlim; - real_rlimit = dlsym(RTLD_NEXT, "setrlimit"); - assert(real_rlimit != NULL); + if (real_rlimit == NULL) { + real_rlimit = dlsym(RTLD_NEXT, "setrlimit"); + assert(real_rlimit); + } memcpy(&my_rlim, rlim, sizeof(struct rlimit)); - if (my_rlim.rlim_cur == 0) { my_rlim.rlim_cur = my_rlim.rlim_max; } -- cgit v1.2.3-60-g2f50