summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-03-19 12:49:56 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-03-19 14:30:52 -0700
commit58073bc12d17341cb9459f36caf161256fc8be19 (patch)
tree946118c7e622deca3e584c0115cb81d97f75c03e
parent0f537ab4913a8d2b3e58a40385a7745c4974bd76 (diff)
Variable scope reductions as recommended by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/XvMC.c24
-rw-r--r--wrapper/XvMCWrapper.c15
2 files changed, 18 insertions, 21 deletions
diff --git a/src/XvMC.c b/src/XvMC.c
index 262469a..cf92662 100644
--- a/src/XvMC.c
+++ b/src/XvMC.c
@@ -115,12 +115,11 @@ XvMCListSurfaceTypes(Display *dpy, XvPortID port, int *num)
surface_info = Xmalloc(rep.num * sizeof(XvMCSurfaceInfo));
if (surface_info) {
- xvmcSurfaceInfo sinfo;
- CARD32 i;
-
*num = rep.num;
- for (i = 0; i < rep.num; i++) {
+ for (CARD32 i = 0; i < rep.num; i++) {
+ xvmcSurfaceInfo sinfo;
+
_XRead(dpy, (char *) &sinfo, sizeof(xvmcSurfaceInfo));
surface_info[i].surface_type_id = sinfo.surface_type_id;
surface_info[i].chroma_format = sinfo.chroma_format;
@@ -173,12 +172,11 @@ XvMCListSubpictureTypes(Display *dpy,
ret = Xmalloc(rep.num * sizeof(XvImageFormatValues));
if (ret) {
- xvImageFormatInfo Info;
- CARD32 i;
-
*count_return = rep.num;
- for (i = 0; i < rep.num; i++) {
+ for (CARD32 i = 0; i < rep.num; i++) {
+ xvImageFormatInfo Info;
+
_XRead(dpy, (char *) (&Info), sz_xvImageFormatInfo);
ret[i].id = Info.id;
ret[i].type = Info.type;
@@ -477,16 +475,10 @@ XvMCGetDRInfo(Display *dpy, XvPortID port,
XExtDisplayInfo *info = xvmc_find_display(dpy);
xvmcGetDRInfoReply rep;
xvmcGetDRInfoReq *req;
- CARD32 magic;
#ifdef HAVE_SHMAT
int shmKey;
volatile CARD32 *shMem;
- struct timezone here;
- struct timeval now;
-
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
#endif
*name = NULL;
@@ -498,7 +490,6 @@ XvMCGetDRInfo(Display *dpy, XvPortID port,
XvMCGetReq(GetDRInfo, req);
req->port = port;
- magic = 0;
req->magic = 0;
#ifdef HAVE_SHMAT
shmKey = shmget(IPC_PRIVATE, 1024, IPC_CREAT | 0600);
@@ -520,6 +511,9 @@ XvMCGetDRInfo(Display *dpy, XvPortID port,
register volatile CARD32 *shMemC = shMem;
register int i;
+ CARD32 magic;
+ struct timezone here = {0, 0};
+ struct timeval now;
gettimeofday(&now, &here);
magic = now.tv_usec & 0x000FFFFF;
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);