summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-06-22 13:35:12 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-07-05 21:14:56 -0700
commite73a2199f039e9ae772efb6be8d1db68eb346fa4 (patch)
treeee89fed11d051ae5606240933ecd58c4d9368ba0
parent4ced44196d6636006c9724a373c0d2ca0c12dc1e (diff)
Use pad_to_int32 macro instead of repeated (x + 3) & ~3 pattern
Makes code clearer, and using ~3U instead of ~3 clears some signed int warnings. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/Xv.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Xv.c b/src/Xv.c
index c87c6cd..b4e2158 100644
--- a/src/Xv.c
+++ b/src/Xv.c
@@ -79,6 +79,8 @@ static const char *xv_extension_name = XvName;
#define XvCheckExtension(dpy, i, val) \
XextCheckExtension(dpy, i, xv_extension_name, val)
+#define pad_to_int32(bytes) (((bytes) + 3) & ~3U)
+
static char *xv_error_string(Display *dpy, int code, XExtCodes *codes,
char *buf, int n);
static int xv_close_display(Display *dpy, XExtCodes *codes);
@@ -236,7 +238,7 @@ XvQueryAdaptors(
/* GET ADAPTOR NAME */
size = u.pa->name_size;
- u.buffer += (sz_xvAdaptorInfo + 3) & ~3;
+ u.buffer += pad_to_int32(sz_xvAdaptorInfo);
if ((name = Xmalloc(size + 1)) == NULL) {
XvFreeAdaptorInfo(pas);
@@ -249,7 +251,7 @@ XvQueryAdaptors(
name[size] = '\0';
pa->name = name;
- u.buffer += (size + 3) & ~3;
+ u.buffer += pad_to_int32(size);
/* GET FORMATS */
@@ -268,7 +270,7 @@ XvQueryAdaptors(
pf->visual_id = u.pf->visual;
pf++;
- u.buffer += (sz_xvFormat + 3) & ~3;
+ u.buffer += pad_to_int32(sz_xvFormat);
}
pa->formats = pfs;
@@ -386,7 +388,7 @@ XvQueryEncodings(
pe->num_encodings = rep.num_encodings - jj;
size = u.pe->name_size;
- u.buffer += (sz_xvEncodingInfo + 3) & ~3;
+ u.buffer += pad_to_int32(sz_xvEncodingInfo);
if ((name = Xmalloc(size + 1)) == NULL) {
XvFreeEncodingInfo(pes);
@@ -400,7 +402,7 @@ XvQueryEncodings(
pe->name = name;
pe++;
- u.buffer += (size + 3) & ~3;
+ u.buffer += pad_to_int32(size);
}
*p_nEncodings = rep.num_encodings;