Skip to content

Commit 3e292b9

Browse files
author
The Android Open Source Project
committed
auto import from //branches/cupcake/...@132569
1 parent 261ed75 commit 3e292b9

File tree

3 files changed

+20
-77
lines changed

3 files changed

+20
-77
lines changed

libpixelflinger/scanline.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ void scanline_perspective_single(context_t* c)
12561256
void scanline_t32cb16(context_t* c)
12571257
{
12581258
int32_t x = c->iterators.xl;
1259-
size_t ct = c->iterators.xr - x;
1259+
size_t ct = c->iterators.xr - x;
12601260
int32_t y = c->iterators.y;
12611261
surface_t* cb = &(c->state.buffers.color);
12621262
union {
@@ -1282,7 +1282,7 @@ void scanline_t32cb16(context_t* c)
12821282
ct--;
12831283
}
12841284

1285-
while (ct > 0) {
1285+
while (ct >= 2) {
12861286
s = GGL_RGBA_TO_HOST( *src++ );
12871287
sR = (s >> ( 3))&0x1F;
12881288
sG = (s >> ( 8+2))&0x3F;

logcat/event-log-tags

+3
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,6 @@
341341
# 0 for screen off, 1 for screen on, 2 for key-guard done
342342
70000 screen_toggled (screen_state|1|5)
343343

344+
# browser stats for diary study
345+
70101 browser_zoom_level_change (start level|1|5),(end level|1|5),(time|2|3)
346+
70102 browser_double_tap_duration (duration|1|3),(time|2|3)

vold/misc.c

+15-75
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ void *read_file(char *filename, ssize_t *_size)
4949

5050
/* slurp it into our buffer */
5151
ret = read(fd, buffer, size);
52-
if (ret != size) {
53-
free(buffer);
54-
buffer = NULL;
52+
if (ret != size)
5553
goto bail;
56-
}
5754

5855
/* let the caller know how big it is */
5956
*_size = size;
@@ -62,90 +59,33 @@ void *read_file(char *filename, ssize_t *_size)
6259
close(fd);
6360
return buffer;
6461
}
65-
66-
char *truncate_sysfs_path(char *path, int count, char *buffer, size_t bufflen)
62+
char *truncate_sysfs_path(char *path, int num_elements_to_remove, char *buffer)
6763
{
68-
char* p;
64+
int i;
6965

70-
strlcpy(buffer, path, bufflen);
71-
p = buffer + strlen(buffer);
66+
strcpy(buffer, path);
7267

73-
for ( ; count > 0; count-- ) {
74-
while (p > buffer && p[-1] != '/') {
75-
p--;
76-
}
77-
if (p == buffer)
78-
break;
68+
for (i = 0; i < num_elements_to_remove; i++) {
69+
char *p = &buffer[strlen(buffer)-1];
7970

80-
p -= 1;
71+
for (p = &buffer[strlen(buffer) -1]; *p != '/'; p--);
72+
*p = '\0';
8173
}
82-
p[0] = '\0';
8374

8475
return buffer;
8576
}
8677

87-
/* used to read the first line of a /sys file into a heap-allocated buffer
88-
* this assumes that reading the file returns a list of zero-terminated strings,
89-
* each could also have a terminating \n before the 0
90-
*
91-
* returns NULL on error, of a new string on success, which must be freed by the
92-
* caller.
93-
*/
94-
char *read_first_line_of(const char* filepath)
78+
char *read_sysfs_var(char *buffer, size_t maxlen, char *devpath, char *var)
9579
{
96-
char *p, *q, *line;
97-
size_t len;
80+
char filename[255];
81+
char *p;
9882
ssize_t sz;
9983

100-
p = read_file((char*)filepath, &sz);
101-
if (p == NULL)
102-
goto FAIL;
103-
104-
/* search end of first line */
105-
q = memchr(p, sz, '\0');
106-
if (q == NULL)
107-
q = p + sz; /* let's be flexible */
108-
109-
len = (size_t)(q - p); /* compute line length */
110-
if (len == 0)
111-
goto FAIL;
112-
113-
if (p[len-1] == '\n') { /* strip trailing \n */
114-
len -= 1;
115-
if (len == 0)
116-
goto FAIL;
117-
}
118-
119-
line = malloc(len+1);
120-
if (line == NULL)
121-
goto FAIL;
122-
123-
memcpy(line, p, len);
124-
line[len] = 0;
84+
sprintf(filename, "/sys%s/%s", devpath, var);
85+
p = read_file(filename, &sz);
86+
p[(strlen(p) - 1)] = '\0';
87+
strncpy(buffer, p, maxlen);
12588
free(p);
126-
127-
return line;
128-
129-
FAIL:
130-
if (p != NULL)
131-
free(p);
132-
133-
return NULL;
134-
}
135-
136-
char *read_sysfs_var(char *buffer, size_t maxlen, char *devpath, char *var)
137-
{
138-
char filename[255], *line;
139-
140-
snprintf(filename, sizeof filename, "/sys%s/%s", devpath, var);
141-
142-
line = read_first_line_of(filename);
143-
if (line == NULL)
144-
return NULL;
145-
146-
snprintf(buffer, maxlen, "%s", line);
147-
free(line);
148-
14989
return buffer;
15090
}
15191

0 commit comments

Comments
 (0)