From 58073bc12d17341cb9459f36caf161256fc8be19 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 19 Mar 2023 12:49:56 -0700 Subject: Variable scope reductions as recommended by cppcheck Signed-off-by: Alan Coopersmith --- wrapper/XvMCWrapper.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'wrapper/XvMCWrapper.c') diff --git a/wrapper/XvMCWrapper.c b/wrapper/XvMCWrapper.c index 7a07634..35c74ee 100644 --- a/wrapper/XvMCWrapper.c +++ b/wrapper/XvMCWrapper.c @@ -222,13 +222,14 @@ dlopenversion(const char *lib, const char *version, int flag) void *ret; int curLen, verLen; char *curName; - const char *tail; curLen = strlen(lib) + (verLen = strlen(version)) + 1; curName = (char *) malloc(curLen * sizeof(char)); strncpy(curName, lib, curLen); if (verLen > 1) { - if (NULL != (tail = strstr(version + 1, "."))) { + const char *tail = strstr(version + 1, "."); + + if (NULL != tail) { strncat(curName, version, tail - version); } else { @@ -279,13 +280,9 @@ initW(Display *dpy, XvPortID port) { char nameBuffer[BUFLEN]; void *handle; - int tmp; char *clientName = NULL; char *err; - FILE *configFile; int nameLen = 0; - int major, minor, patchLevel, isLocal; - char *busID = NULL; wrapperInit = 1; xW.initialised = 0; @@ -302,6 +299,9 @@ initW(Display *dpy, XvPortID port) dlsym(handle2, "XvMCGetDRInfo"); if ((err = dlerror()) == NULL) { + int major, minor, patchLevel, isLocal; + char *busID = NULL; + if (0 == xW.XvMCGetDRInfo(dpy, port, &clientName, &busID, &major, &minor, &patchLevel, &isLocal)) { nameLen = strlen(clientName); @@ -332,6 +332,9 @@ initW(Display *dpy, XvPortID port) * No. Try to obtain it from the config file. */ + int tmp; + FILE *configFile; + if (clientName) XFree(clientName); -- cgit v1.2.3