diff options
-rw-r--r-- | edify/Android.mk | 7 | ||||
-rw-r--r-- | edify/main.c | 3 | ||||
-rw-r--r-- | minadbd/adb.c | 2 | ||||
-rw-r--r-- | mtdutils/mounts.c | 89 | ||||
-rw-r--r-- | tests/Android.mk | 47 | ||||
-rw-r--r-- | uncrypt/uncrypt.c | 1 | ||||
-rw-r--r-- | updater/Android.mk | 2 | ||||
-rw-r--r-- | verifier_test.cpp | 5 |
8 files changed, 48 insertions, 108 deletions
diff --git a/edify/Android.mk b/edify/Android.mk index 61ed6fa17..03c04e432 100644 --- a/edify/Android.mk +++ b/edify/Android.mk @@ -7,9 +7,10 @@ edify_src_files := \ parser.y \ expr.c -# "-x c" forces the lex/yacc files to be compiled as c; -# the build system otherwise forces them to be c++. -edify_cflags := -x c +# "-x c" forces the lex/yacc files to be compiled as c the build system +# otherwise forces them to be c++. Need to also add an explicit -std because the +# build system will soon default C++ to -std=c++11. +edify_cflags := -x c -std=gnu89 # # Build the host-side command line tool diff --git a/edify/main.c b/edify/main.c index b3fad53b8..b1baa0b13 100644 --- a/edify/main.c +++ b/edify/main.c @@ -25,13 +25,12 @@ extern int yyparse(Expr** root, int* error_count); int expect(const char* expr_str, const char* expected, int* errors) { Expr* e; - int error; char* result; printf("."); int error_count = parse_string(expr_str, &e, &error_count); - if (error > 0 || error_count > 0) { + if (error_count > 0) { printf("error parsing \"%s\" (%d errors)\n", expr_str, error_count); ++*errors; diff --git a/minadbd/adb.c b/minadbd/adb.c index 127d072be..0ac16e4d9 100644 --- a/minadbd/adb.c +++ b/minadbd/adb.c @@ -379,7 +379,7 @@ static void adb_cleanup(void) int adb_main() { atexit(adb_cleanup); -#if defined(HAVE_FORKEXEC) +#if !defined(_WIN32) // No SIGCHLD. Let the service subproc handle its children. signal(SIGPIPE, SIG_IGN); #endif diff --git a/mtdutils/mounts.c b/mtdutils/mounts.c index c90fc8acf..6a9b03d30 100644 --- a/mtdutils/mounts.c +++ b/mtdutils/mounts.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include <mntent.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -59,10 +60,8 @@ free_volume_internals(const MountedVolume *volume, int zero) int scan_mounted_volumes() { - char buf[2048]; - const char *bufp; - int fd; - ssize_t nbytes; + FILE* fp; + struct mntent* mentry; if (g_mounts_state.volumes == NULL) { const int numv = 32; @@ -84,80 +83,20 @@ scan_mounted_volumes() } g_mounts_state.volume_count = 0; - /* Open and read the file contents. - */ - fd = open(PROC_MOUNTS_FILENAME, O_RDONLY); - if (fd < 0) { - goto bail; - } - nbytes = read(fd, buf, sizeof(buf) - 1); - close(fd); - if (nbytes < 0) { - goto bail; + /* Open and read mount table entries. */ + fp = setmntent(PROC_MOUNTS_FILENAME, "r"); + if (fp == NULL) { + return -1; } - buf[nbytes] = '\0'; - - /* Parse the contents of the file, which looks like: - * - * # cat /proc/mounts - * rootfs / rootfs rw 0 0 - * /dev/pts /dev/pts devpts rw 0 0 - * /proc /proc proc rw 0 0 - * /sys /sys sysfs rw 0 0 - * /dev/block/mtdblock4 /system yaffs2 rw,nodev,noatime,nodiratime 0 0 - * /dev/block/mtdblock5 /data yaffs2 rw,nodev,noatime,nodiratime 0 0 - * /dev/block/mmcblk0p1 /sdcard vfat rw,sync,dirsync,fmask=0000,dmask=0000,codepage=cp437,iocharset=iso8859-1,utf8 0 0 - * - * The zeroes at the end are dummy placeholder fields to make the - * output match Linux's /etc/mtab, but don't represent anything here. - */ - bufp = buf; - while (nbytes > 0) { - char device[64]; - char mount_point[64]; - char filesystem[64]; - char flags[128]; - int matches; - - /* %as is a gnu extension that malloc()s a string for each field. - */ - matches = sscanf(bufp, "%63s %63s %63s %127s", - device, mount_point, filesystem, flags); - - if (matches == 4) { - device[sizeof(device)-1] = '\0'; - mount_point[sizeof(mount_point)-1] = '\0'; - filesystem[sizeof(filesystem)-1] = '\0'; - flags[sizeof(flags)-1] = '\0'; - - MountedVolume *v = - &g_mounts_state.volumes[g_mounts_state.volume_count++]; - v->device = strdup(device); - v->mount_point = strdup(mount_point); - v->filesystem = strdup(filesystem); - v->flags = strdup(flags); - } else { -printf("matches was %d on <<%.40s>>\n", matches, bufp); - } - - /* Eat the line. - */ - while (nbytes > 0 && *bufp != '\n') { - bufp++; - nbytes--; - } - if (nbytes > 0) { - bufp++; - nbytes--; - } + while ((mentry = getmntent(fp)) != NULL) { + MountedVolume* v = &g_mounts_state.volumes[g_mounts_state.volume_count++]; + v->device = strdup(mentry->mnt_fsname); + v->mount_point = strdup(mentry->mnt_dir); + v->filesystem = strdup(mentry->mnt_type); + v->flags = strdup(mentry->mnt_opts); } - + endmntent(fp); return 0; - -bail: -//TODO: free the strings we've allocated. - g_mounts_state.volume_count = 0; - return -1; } const MountedVolume * diff --git a/tests/Android.mk b/tests/Android.mk index 4d99d5249..02a272a24 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -1,26 +1,25 @@ -# Build the unit tests. -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# Build the unit tests. -test_src_files := \ - asn1_decoder_test.cpp +# +# Copyright (C) 2014 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# -shared_libraries := \ - liblog \ - libcutils - -static_libraries := \ - libgtest \ - libgtest_main \ - libverifier +LOCAL_PATH := $(call my-dir) -$(foreach file,$(test_src_files), \ - $(eval include $(CLEAR_VARS)) \ - $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \ - $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \ - $(eval LOCAL_SRC_FILES := $(file)) \ - $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \ - $(eval LOCAL_C_INCLUDES := $(LOCAL_PATH)/..) \ - $(eval include $(BUILD_NATIVE_TEST)) \ -)
\ No newline at end of file +include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk +LOCAL_STATIC_LIBRARIES := libverifier +LOCAL_SRC_FILES := asn1_decoder_test.cpp +LOCAL_MODULE := asn1_decoder_test +LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. +include $(BUILD_NATIVE_TEST) diff --git a/uncrypt/uncrypt.c b/uncrypt/uncrypt.c index 7fb0989a7..7f1a01a80 100644 --- a/uncrypt/uncrypt.c +++ b/uncrypt/uncrypt.c @@ -39,6 +39,7 @@ // Recovery can take this block map file and retrieve the underlying // file data to use as an update package. +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <stdarg.h> diff --git a/updater/Android.mk b/updater/Android.mk index 11e7bb807..ff02a33b0 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -79,7 +79,7 @@ $(inc) : $(inc_dep_file) $(hide) $(foreach lib,$(libs),echo " Register_$(lib)();" >> $@;) $(hide) echo "}" >> $@ -$(call intermediates-dir-for,EXECUTABLES,updater)/updater.o : $(inc) +$(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater.o : $(inc) LOCAL_C_INCLUDES += $(dir $(inc)) inc := diff --git a/verifier_test.cpp b/verifier_test.cpp index 10a5ddaad..e2f3d105c 100644 --- a/verifier_test.cpp +++ b/verifier_test.cpp @@ -14,12 +14,13 @@ * limitations under the License. */ +#include <errno.h> +#include <fcntl.h> +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> -#include <stdarg.h> #include <sys/types.h> #include <sys/stat.h> -#include <fcntl.h> #include "common.h" #include "verifier.h" |