From: Andreas Schneider Date: Tue, 24 Mar 2015 14:04:11 +0000 (+0100) Subject: libv4l2: Correctly initialize structures X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7d7d9d39959a9cf732e480ef8379601bddbb6a3f;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_exynos.git libv4l2: Correctly initialize structures This uses C99 initializers so that structs are zeroed if no value has been specified. Change-Id: I00274262d86035318b68406e4826e6e095aec8d6 Signed-off-by: Andreas Schneider --- diff --git a/libv4l2/exynos_v4l2.c b/libv4l2/exynos_v4l2.c index 0110f7f..345fd5a 100644 --- a/libv4l2/exynos_v4l2.c +++ b/libv4l2/exynos_v4l2.c @@ -195,7 +195,9 @@ int exynos_v4l2_close(int fd) bool exynos_v4l2_enuminput(int fd, int index, char *input_name_buf) { int ret = -1; - struct v4l2_input input; + struct v4l2_input input = { + .index = index, + }; Exynos_v4l2_In(); @@ -204,7 +206,6 @@ bool exynos_v4l2_enuminput(int fd, int index, char *input_name_buf) return NULL; } - input.index = index; ret = ioctl(fd, VIDIOC_ENUMINPUT, &input, 32); if (ret) { ALOGE("%s: no matching index founds", __func__); @@ -223,7 +224,9 @@ bool exynos_v4l2_enuminput(int fd, int index, char *input_name_buf) int exynos_v4l2_s_input(int fd, int index) { int ret = -1; - struct v4l2_input input; + struct v4l2_input input = { + .index = index, + }; Exynos_v4l2_In(); @@ -232,8 +235,6 @@ int exynos_v4l2_s_input(int fd, int index) return ret; } - input.index = index; - ret = ioctl(fd, VIDIOC_S_INPUT, &input); if (ret){ ALOGE("failed to ioctl: VIDIOC_S_INPUT (%d - %s)", errno, strerror(errno)); @@ -286,14 +287,14 @@ bool exynos_v4l2_querycap(int fd, unsigned int need_caps) bool exynos_v4l2_enum_fmt(int fd, enum v4l2_buf_type type, unsigned int fmt) { - struct v4l2_fmtdesc fmtdesc; + struct v4l2_fmtdesc fmtdesc = { + .index = 0, + .type = type, + }; int found = 0; Exynos_v4l2_In(); - fmtdesc.type = type; - fmtdesc.index = 0; - while (ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc) == 0) { if (fmtdesc.pixelformat == fmt) { ALOGE("Passed fmt = %#x found pixel format[%d]: %s", fmt, fmtdesc.index, fmtdesc.description); @@ -737,13 +738,13 @@ int exynos_v4l2_g_ctrl(int fd, unsigned int id, int *value) int exynos_v4l2_s_ctrl(int fd, unsigned int id, int value) { int ret = -1; - struct v4l2_control ctrl; + struct v4l2_control ctrl = { + .id = id, + .value = value, + }; Exynos_v4l2_In(); - ctrl.id = id; - ctrl.value = value; - if (fd < 0) { ALOGE("%s: invalid fd: %d", __func__, fd); return ret;