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 --- src/XvMC.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/XvMC.c') 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; -- cgit v1.2.3