summaryrefslogtreecommitdiffstats
path: root/adb/framebuffer_service.c
diff options
context:
space:
mode:
authorChris Dearman <chris.dearman@imgtec.com>2013-09-25 02:19:40 -0700
committerChris Dearman <chris.dearman@imgtec.com>2013-09-25 02:43:45 -0700
commit85373f42803f86e3295afd5031a0e42e0b3bef33 (patch)
treee0746201773856c1589c8c9b243a9e493e0ab19e /adb/framebuffer_service.c
parentf2c4c4ada725b86e6581a89cc06e2836d4bdc6e3 (diff)
downloadcore-85373f42803f86e3295afd5031a0e42e0b3bef33.tar.gz
core-85373f42803f86e3295afd5031a0e42e0b3bef33.tar.bz2
core-85373f42803f86e3295afd5031a0e42e0b3bef33.zip
Handle screendumps for all framebuffer sizes
readx() treats a partial read as an error but also consumes the data, Now exactly the amount of data needed for the screendump is requested. This bug showed up for framebuffers that were not a multiple of 640 bytes. Also fix a compiler warning related to handing pipe() failure. Change-Id: I8b1713923e156d4e3424784152e5dc5cbc7d478d
Diffstat (limited to 'adb/framebuffer_service.c')
-rw-r--r--adb/framebuffer_service.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/adb/framebuffer_service.c b/adb/framebuffer_service.c
index 20c08d23f..fa7fd98dc 100644
--- a/adb/framebuffer_service.c
+++ b/adb/framebuffer_service.c
@@ -55,13 +55,13 @@ struct fbinfo {
void framebuffer_service(int fd, void *cookie)
{
struct fbinfo fbinfo;
- unsigned int i;
+ unsigned int i, bsize;
char buf[640];
int fd_screencap;
int w, h, f;
int fds[2];
- if (pipe(fds) < 0) goto done;
+ if (pipe(fds) < 0) goto pipefail;
pid_t pid = fork();
if (pid < 0) goto done;
@@ -164,17 +164,19 @@ void framebuffer_service(int fd, void *cookie)
if(writex(fd, &fbinfo, sizeof(fbinfo))) goto done;
/* write data */
- for(i = 0; i < fbinfo.size; i += sizeof(buf)) {
- if(readx(fd_screencap, buf, sizeof(buf))) goto done;
- if(writex(fd, buf, sizeof(buf))) goto done;
+ for(i = 0; i < fbinfo.size; i += bsize) {
+ bsize = sizeof(buf);
+ if (i + bsize > fbinfo.size)
+ bsize = fbinfo.size - i;
+ if(readx(fd_screencap, buf, bsize)) goto done;
+ if(writex(fd, buf, bsize)) goto done;
}
- if(readx(fd_screencap, buf, fbinfo.size % sizeof(buf))) goto done;
- if(writex(fd, buf, fbinfo.size % sizeof(buf))) goto done;
done:
TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
close(fds[0]);
close(fds[1]);
+pipefail:
close(fd);
}