[PATCH v2 weston] compositor: Respect WESTON_BUILD_DIR env var in weston_load_module
Jon A. Cruz
jonc at osg.samsung.com
Tue Jun 9 17:23:15 PDT 2015
On 06/09/2015 04:55 PM, Derek Foreman wrote:
> On 09/06/15 06:24 PM, Jon A. Cruz wrote:
>> On 06/08/2015 09:46 AM, Derek Foreman wrote:
>>> We were loading modules out of the system dirs unconditionally, so
>>> tests that loaded modules would use the system ones, or fail if
>>> they weren't installed.
>>>
>>> Reviewed-By: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
>>> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
>>> ---
>>> src/compositor.c | 11 ++++++++---
>>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/src/compositor.c b/src/compositor.c
>>> index 8f02b4d..3196e5a 100644
>>> --- a/src/compositor.c
>>> +++ b/src/compositor.c
>>> @@ -4906,16 +4906,21 @@ on_caught_signal(int s, siginfo_t *siginfo, void *context)
>>> WL_EXPORT void *
>>> weston_load_module(const char *name, const char *entrypoint)
>>> {
>>> + const char *builddir = getenv("WESTON_BUILD_DIR");
>>> char path[PATH_MAX];
>>> void *module, *init;
>>>
>>> if (name == NULL)
>>> return NULL;
>>>
>>> - if (name[0] != '/')
>>> - snprintf(path, sizeof path, "%s/%s", MODULEDIR, name);
>>> - else
>>> + if (name[0] != '/') {
>>> + if (builddir)
>>> + snprintf(path, sizeof path, "%s/.libs/%s", builddir, name);
>>> + else
>>> + snprintf(path, sizeof path, "%s/%s", MODULEDIR, name);
>>> + } else {
>>> snprintf(path, sizeof path, "%s", name);
>>> + }
>>>
>>> module = dlopen(path, RTLD_NOW | RTLD_NOLOAD);
>>> if (module) {
>>
>> After the calls to snprintf, for safety the last byte of the 'path'
>> buffer should be explicitly zeroed as technically null-termination is
>> not guaranteed.
>
> You're thinking of strncpy().
OK. Looks good then. Also was an issue tripping me up in test fixture
testing, so this is helpful immediately.
Reviewed-by: Jon A. Cruz <jonc at osg.samsung.com>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
--
Jon A. Cruz - Senior Open Source Developer
Samsung Open Source Group
jonc at osg.samsung.com
More information about the wayland-devel
mailing list