Loading libpixelflinger/scanline.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1282,7 +1282,7 @@ last_one: ct--; } while (ct > 0) { while (ct >= 2) { s = GGL_RGBA_TO_HOST( *src++ ); sR = (s >> ( 3))&0x1F; sG = (s >> ( 8+2))&0x3F; Loading logcat/event-log-tags +3 −0 Original line number Diff line number Diff line Loading @@ -341,3 +341,6 @@ # 0 for screen off, 1 for screen on, 2 for key-guard done 70000 screen_toggled (screen_state|1|5) # browser stats for diary study 70101 browser_zoom_level_change (start level|1|5),(end level|1|5),(time|2|3) 70102 browser_double_tap_duration (duration|1|3),(time|2|3) No newline at end of file vold/misc.c +15 −75 Original line number Diff line number Diff line Loading @@ -49,11 +49,8 @@ void *read_file(char *filename, ssize_t *_size) /* slurp it into our buffer */ ret = read(fd, buffer, size); if (ret != size) { free(buffer); buffer = NULL; if (ret != size) goto bail; } /* let the caller know how big it is */ *_size = size; Loading @@ -62,90 +59,33 @@ bail: close(fd); return buffer; } char *truncate_sysfs_path(char *path, int count, char *buffer, size_t bufflen) char *truncate_sysfs_path(char *path, int num_elements_to_remove, char *buffer) { char* p; int i; strlcpy(buffer, path, bufflen); p = buffer + strlen(buffer); strcpy(buffer, path); for ( ; count > 0; count-- ) { while (p > buffer && p[-1] != '/') { p--; } if (p == buffer) break; for (i = 0; i < num_elements_to_remove; i++) { char *p = &buffer[strlen(buffer)-1]; p -= 1; for (p = &buffer[strlen(buffer) -1]; *p != '/'; p--); *p = '\0'; } p[0] = '\0'; return buffer; } /* used to read the first line of a /sys file into a heap-allocated buffer * this assumes that reading the file returns a list of zero-terminated strings, * each could also have a terminating \n before the 0 * * returns NULL on error, of a new string on success, which must be freed by the * caller. */ char *read_first_line_of(const char* filepath) char *read_sysfs_var(char *buffer, size_t maxlen, char *devpath, char *var) { char *p, *q, *line; size_t len; char filename[255]; char *p; ssize_t sz; p = read_file((char*)filepath, &sz); if (p == NULL) goto FAIL; /* search end of first line */ q = memchr(p, sz, '\0'); if (q == NULL) q = p + sz; /* let's be flexible */ len = (size_t)(q - p); /* compute line length */ if (len == 0) goto FAIL; if (p[len-1] == '\n') { /* strip trailing \n */ len -= 1; if (len == 0) goto FAIL; } line = malloc(len+1); if (line == NULL) goto FAIL; memcpy(line, p, len); line[len] = 0; sprintf(filename, "/sys%s/%s", devpath, var); p = read_file(filename, &sz); p[(strlen(p) - 1)] = '\0'; strncpy(buffer, p, maxlen); free(p); return line; FAIL: if (p != NULL) free(p); return NULL; } char *read_sysfs_var(char *buffer, size_t maxlen, char *devpath, char *var) { char filename[255], *line; snprintf(filename, sizeof filename, "/sys%s/%s", devpath, var); line = read_first_line_of(filename); if (line == NULL) return NULL; snprintf(buffer, maxlen, "%s", line); free(line); return buffer; } Loading
libpixelflinger/scanline.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1282,7 +1282,7 @@ last_one: ct--; } while (ct > 0) { while (ct >= 2) { s = GGL_RGBA_TO_HOST( *src++ ); sR = (s >> ( 3))&0x1F; sG = (s >> ( 8+2))&0x3F; Loading
logcat/event-log-tags +3 −0 Original line number Diff line number Diff line Loading @@ -341,3 +341,6 @@ # 0 for screen off, 1 for screen on, 2 for key-guard done 70000 screen_toggled (screen_state|1|5) # browser stats for diary study 70101 browser_zoom_level_change (start level|1|5),(end level|1|5),(time|2|3) 70102 browser_double_tap_duration (duration|1|3),(time|2|3) No newline at end of file
vold/misc.c +15 −75 Original line number Diff line number Diff line Loading @@ -49,11 +49,8 @@ void *read_file(char *filename, ssize_t *_size) /* slurp it into our buffer */ ret = read(fd, buffer, size); if (ret != size) { free(buffer); buffer = NULL; if (ret != size) goto bail; } /* let the caller know how big it is */ *_size = size; Loading @@ -62,90 +59,33 @@ bail: close(fd); return buffer; } char *truncate_sysfs_path(char *path, int count, char *buffer, size_t bufflen) char *truncate_sysfs_path(char *path, int num_elements_to_remove, char *buffer) { char* p; int i; strlcpy(buffer, path, bufflen); p = buffer + strlen(buffer); strcpy(buffer, path); for ( ; count > 0; count-- ) { while (p > buffer && p[-1] != '/') { p--; } if (p == buffer) break; for (i = 0; i < num_elements_to_remove; i++) { char *p = &buffer[strlen(buffer)-1]; p -= 1; for (p = &buffer[strlen(buffer) -1]; *p != '/'; p--); *p = '\0'; } p[0] = '\0'; return buffer; } /* used to read the first line of a /sys file into a heap-allocated buffer * this assumes that reading the file returns a list of zero-terminated strings, * each could also have a terminating \n before the 0 * * returns NULL on error, of a new string on success, which must be freed by the * caller. */ char *read_first_line_of(const char* filepath) char *read_sysfs_var(char *buffer, size_t maxlen, char *devpath, char *var) { char *p, *q, *line; size_t len; char filename[255]; char *p; ssize_t sz; p = read_file((char*)filepath, &sz); if (p == NULL) goto FAIL; /* search end of first line */ q = memchr(p, sz, '\0'); if (q == NULL) q = p + sz; /* let's be flexible */ len = (size_t)(q - p); /* compute line length */ if (len == 0) goto FAIL; if (p[len-1] == '\n') { /* strip trailing \n */ len -= 1; if (len == 0) goto FAIL; } line = malloc(len+1); if (line == NULL) goto FAIL; memcpy(line, p, len); line[len] = 0; sprintf(filename, "/sys%s/%s", devpath, var); p = read_file(filename, &sz); p[(strlen(p) - 1)] = '\0'; strncpy(buffer, p, maxlen); free(p); return line; FAIL: if (p != NULL) free(p); return NULL; } char *read_sysfs_var(char *buffer, size_t maxlen, char *devpath, char *var) { char filename[255], *line; snprintf(filename, sizeof filename, "/sys%s/%s", devpath, var); line = read_first_line_of(filename); if (line == NULL) return NULL; snprintf(buffer, maxlen, "%s", line); free(line); return buffer; }