aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-09-04 08:18:21 (GMT)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-09-04 10:20:49 (GMT)
commit16c8f03b7cd32dd040af1771411c9a906af94fe8 (patch)
tree1b93967d5701f69b84bfe06a8ed31501e8167b9e
parent3cada8d74f6a4e82538bc17923f27bd3e03f4e8e (diff)
Do some code cleanups
When building it with: CFLAGS="-Wall -Wstrict-prototypes -Wnested-externs -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -Werror=missing-include-dirs -Werror=return-type" Lots of warning appear. Clean up the most trivial ones. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r--src/callbacks.c53
-rw-r--r--src/camorama-filter-laplace.c2
-rw-r--r--src/camorama-filter-mirror.c2
-rw-r--r--src/camorama-filter-reichardt.c2
-rw-r--r--src/camorama-stock-items.c5
-rw-r--r--src/camorama-window.c5
-rw-r--r--src/fileio.c29
-rw-r--r--src/fileio.h2
-rw-r--r--src/filter.c28
-rw-r--r--src/filter.h2
-rw-r--r--src/main.c15
-rw-r--r--src/v4l.c14
-rw-r--r--src/v4l.h13
13 files changed, 88 insertions, 84 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index f678c2d..5f6281a 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -282,15 +282,18 @@ int delete_event (GtkWidget * widget, gpointer data)
static int apply_remote_pref(cam_t *cam)
{
+ int index;
+ gchar *host, *rdir, *proto, *rfile, *uri;
+
if (!strlen (gtk_entry_get_text ((GtkEntry *) host_entry)))
return 0;
- int index = gtk_combo_box_get_active(GTK_COMBO_BOX(protocol));
+ index = gtk_combo_box_get_active(GTK_COMBO_BOX(protocol));
- gchar *host = g_strdup (gtk_entry_get_text ((GtkEntry *) host_entry));
- gchar *rdir = g_strdup (gtk_entry_get_text ((GtkEntry *) rdir_entry));
- gchar *proto = g_strdup (protos[index]);
- gchar *rfile = g_strdup (gtk_entry_get_text ((GtkEntry *) filename_entry));
+ host = g_strdup (gtk_entry_get_text ((GtkEntry *) host_entry));
+ rdir = g_strdup (gtk_entry_get_text ((GtkEntry *) rdir_entry));
+ proto = g_strdup (protos[index]);
+ rfile = g_strdup (gtk_entry_get_text ((GtkEntry *) filename_entry));
if (!host || !proto || !rdir || !rfile) {
if (host)
@@ -304,7 +307,7 @@ static int apply_remote_pref(cam_t *cam)
return 0;
}
- gchar *uri = volume_uri(host, proto, rdir);
+ uri = volume_uri(host, proto, rdir);
if (cam->rdir_ok) {
/* unmount/mount can spend time. Do only if URI changed */
@@ -399,9 +402,9 @@ void on_preferences1_activate (GtkMenuItem * menuitem, gpointer user_data)
void on_change_size_activate (GtkWidget * widget, cam_t *cam)
{
- gchar const *name;
- gchar *title;
- int width = 0, height = 0;
+ gchar const *name;
+ gchar *title;
+ unsigned int width = 0, height = 0;
name = gtk_widget_get_name (widget);
@@ -564,12 +567,9 @@ static cairo_surface_t *create_from_pixbuf(const GdkPixbuf *pixbuf,
int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
int cairo_stride;
guchar *cairo_pixels;
- cairo_format_t format;
cairo_surface_t *surface;
int j;
- format = CAIRO_FORMAT_RGB24;
-
surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
width, height);
cairo_stride = cairo_image_surface_get_stride (surface);
@@ -629,8 +629,11 @@ static cairo_surface_t *create_from_pixbuf(const GdkPixbuf *pixbuf,
static void show_buffer(cam_t *cam)
{
- int i;
GdkPixbuf *pb;
+ GtkWidget *widget;
+ GdkWindow *window;
+ cairo_surface_t *surface;
+ cairo_t *cr;
unsigned char *pic_buf = cam->pic_buf;
const GdkRectangle rect = {
.x = 0, .y = 0,
@@ -654,11 +657,11 @@ static void show_buffer(cam_t *cam)
(cam->width * cam->bpp / 8), NULL,
NULL);
- GtkWidget *widget = GTK_WIDGET(gtk_builder_get_object(cam->xml, "da"));
- GdkWindow *window = gtk_widget_get_window(widget);
+ widget = GTK_WIDGET(gtk_builder_get_object(cam->xml, "da"));
+ window = gtk_widget_get_window(widget);
- cairo_surface_t *surface = create_from_pixbuf(pb, window);
- cairo_t *cr = gdk_cairo_create(window);
+ surface = create_from_pixbuf(pb, window);
+ cr = gdk_cairo_create(window);
cairo_set_source_surface(cr, surface, 0, 0);
gdk_cairo_rectangle(cr, &rect);
@@ -699,8 +702,7 @@ gint fps (GtkWidget * sb)
seconds++;
stat = g_strdup_printf (_("%.2f fps - current %.2f fps - average"),
- (float) frames / (float) (2),
- (float) frames2 / (float) (seconds * 2));
+ frames / 2., frames2 / (seconds * 2.));
frames = 0;
gtk_statusbar_push (GTK_STATUSBAR(sb), cont, stat);
g_free (stat);
@@ -795,19 +797,6 @@ void wb_change (GtkHScale * sc1, cam_t *cam)
v4l2_set_control(cam->dev, V4L2_CID_WHITENESS, cam->whiteness);
}
-static void help_cb (GtkWidget * widget, gpointer data)
-{
- GError *error = NULL;
-
- if (error != NULL) {
- /*
- * FIXME: This is bad :)
- */
- g_warning ("%s\n", error->message);
- g_error_free (error);
- }
-}
-
void update_tooltip (cam_t *cam)
{
gchar *tooltip_text;
diff --git a/src/camorama-filter-laplace.c b/src/camorama-filter-laplace.c
index 25db6bd..8703595 100644
--- a/src/camorama-filter-laplace.c
+++ b/src/camorama-filter-laplace.c
@@ -41,7 +41,7 @@ static void
camorama_filter_laplace_init(CamoramaFilterLaplace* self) {}
static void
-camorama_filter_laplace_filter(CamoramaFilter* filter, guchar *image, int width, int height, int depth) {
+camorama_filter_laplace_filter(void *filter, guchar *image, int width, int height, int depth) {
int x, y;
unsigned char *image2;
diff --git a/src/camorama-filter-mirror.c b/src/camorama-filter-mirror.c
index 9ed5724..ea65269 100644
--- a/src/camorama-filter-mirror.c
+++ b/src/camorama-filter-mirror.c
@@ -39,7 +39,7 @@ static void
camorama_filter_mirror_init(CamoramaFilterMirror* self) {}
static void
-camorama_filter_mirror_filter(CamoramaFilter* filter, guchar *image, gint width, gint height, gint depth) {
+camorama_filter_mirror_filter(void * filter, guchar *image, gint width, gint height, gint depth) {
gint x, z, row_length, image_length, new_row, next_row, half_row, index1, index2;
guchar temp;
diff --git a/src/camorama-filter-reichardt.c b/src/camorama-filter-reichardt.c
index a0e8cb5..9e2149b 100644
--- a/src/camorama-filter-reichardt.c
+++ b/src/camorama-filter-reichardt.c
@@ -150,7 +150,7 @@ static void MaybeNewMemory(gint width, gint height, gint depth)
static void
-camorama_filter_reichardt_filter(CamoramaFilter* filter, guchar *image, gint width, gint height, gint depth)
+camorama_filter_reichardt_filter(void *filter, guchar *image, gint width, gint height, gint depth)
{
gint x, y, z, row_length, row, column, thisPixel, thisXY, thatXY;
diff --git a/src/camorama-stock-items.c b/src/camorama-stock-items.c
index 94ff906..64b507c 100644
--- a/src/camorama-stock-items.c
+++ b/src/camorama-stock-items.c
@@ -7,12 +7,15 @@
#include <glib/gi18n.h>
#include "v4l.h"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
static GtkStockItem camorama_items[] = {
{CAMORAMA_STOCK_WEBCAM, N_("Webcam"), 0, 0, "camorama"}
};
+#pragma GCC diagnostic pop
static void
-add_default_image(const gchar* stock_id, gint size, gchar *pixfilename)
+add_default_image(const gchar* stock_id, gint size, const gchar *pixfilename)
{
GdkPixbuf* buf = gdk_pixbuf_new_from_file(pixfilename, NULL);
g_return_if_fail(buf);
diff --git a/src/camorama-window.c b/src/camorama-window.c
index a4565c8..97d2d91 100644
--- a/src/camorama-window.c
+++ b/src/camorama-window.c
@@ -188,18 +188,19 @@ tray_clicked_callback (GtkStatusIcon* status, guint button, guint activate_time,
void
load_interface(cam_t *cam) {
- int i;
+ unsigned int i;
gchar *title;
GdkPixbuf *logo = NULL;
GtkCellRenderer* cell;
GtkWidget *small_res, *new_res;
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(cam->xml,
"main_window"));
+ GtkTreeView* treeview;
menu_item_filter_type = g_quark_from_static_string("camorama-menu-item-filter-type");
/* set up the tree view */
- GtkTreeView* treeview = GTK_TREE_VIEW(gtk_builder_get_object(cam->xml, "treeview_effects"));
+ treeview = GTK_TREE_VIEW(gtk_builder_get_object(cam->xml, "treeview_effects"));
cell = gtk_cell_renderer_text_new();
g_object_set(cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
gtk_cell_renderer_text_set_fixed_height_from_font(GTK_CELL_RENDERER_TEXT(cell), 1);
diff --git a/src/fileio.c b/src/fileio.c
index dedda31..28c7add 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -36,6 +36,8 @@ add_rgb_text (guchar *image, int width, int height, char *cstring, char *format,
image_label = g_strdup_printf ("%s", format);
} else if (str == FALSE && date == FALSE) {
return 0;
+ } else {
+ image_label = g_strdup("");
}
time (&t);
@@ -137,8 +139,14 @@ void remote_save (cam_t *cam)
g_free (filename);
- remote_thread =
- g_thread_new ("remote", (GThreadFunc) save_thread, cam);
+ remote_thread = g_thread_new ("remote", &save_thread, cam);
+ if (!remote_thread) {
+ error_message =
+ g_strdup_printf (_("Could not create a thread to save image '%s/%s'."),
+ cam->pixdir, filename);
+ error_dialog (error_message);
+ }
+
g_free (ext);
}
@@ -181,8 +189,6 @@ gchar *volume_uri(gchar *host, gchar *proto, gchar *rdir)
void umount_volume(cam_t *cam)
{
- struct mount_params mount;
-
/* Unmount previous volume */
if (!cam->rdir_ok)
return;
@@ -216,26 +222,24 @@ void mount_volume(cam_t *cam)
cam->rdir_mop, NULL, mount_cb, cam);
}
-void save_thread (cam_t *cam)
+gpointer save_thread (gpointer data)
{
+ cam_t *cam = data;
char *output_uri_string, *input_uri_string;
GFile *uri_1;
GFileOutputStream *fout;
unsigned char *tmp;
- gboolean test;
- char *filename, *error_message;
+ char *error_message;
FILE *fp;
int bytes = 0;
time_t t;
char timenow[64], *ext;
struct tm *tm;
- gboolean pbs;
- GdkPixbuf *pb;
GError *error = NULL;
/* Check if it is ready to mount */
if (!cam->rdir_ok)
- return;
+ return NULL;
switch (cam->rsavetype) {
case JPEG:
@@ -327,11 +331,12 @@ void save_thread (cam_t *cam)
g_object_unref(uri_1);
free (tmp);
g_thread_exit (NULL);
+
+ return NULL;
}
int local_save (cam_t *cam)
{
- int fc;
gchar *filename, *ext;
time_t t;
struct tm *tm;
@@ -362,6 +367,8 @@ int local_save (cam_t *cam)
time (&t);
tm = localtime (&t);
len = strftime (timenow, sizeof (timenow) - 1, "%s", tm);
+ if (len < 0)
+ timenow[0] = '\0';
if (cam->debug == TRUE) {
fprintf (stderr, "time = %s\n", timenow);
diff --git a/src/fileio.h b/src/fileio.h
index 8b34894..61305ea 100644
--- a/src/fileio.h
+++ b/src/fileio.h
@@ -2,7 +2,7 @@
int add_rgb_text (guchar *, int, int, char *, char *, gboolean, gboolean);
void remote_save (cam_t *);
-void save_thread (cam_t *);
+gpointer save_thread (gpointer data);
int local_save (cam_t *);
gchar *volume_uri(gchar *host, gchar *proto, gchar *rdir);
void umount_volume(cam_t *);
diff --git a/src/filter.c b/src/filter.c
index c55e9b8..b866604 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -153,7 +153,6 @@ camorama_filter_color_init(CamoramaFilterColor* self) {}
void
camorama_filter_color_filter(void *__filter, guchar *image, int x, int y, int depth) {
- CamoramaFilterColor *filter = __filter;
int i;
char tmp;
i = x * y;
@@ -181,9 +180,7 @@ static void
camorama_filter_invert_init(CamoramaFilterInvert* self) {}
static void
-camorama_filter_invert_filter(CamoramaFilter* filter, guchar *image, int x, int y, int depth) {
-#warning "FIXME: add a checking cast here"
- CamoramaFilterInvert* self = (CamoramaFilterInvert*)filter;
+camorama_filter_invert_filter(void * filter, guchar *image, int x, int y, int depth) {
int i;
for (i = 0; i < x * y * depth; i++) {
image[i] = 255 - image[i];
@@ -211,9 +208,8 @@ camorama_filter_threshold_init(CamoramaFilterThreshold* self) {
}
static void
-camorama_filter_threshold_filter(CamoramaFilter* filter, guchar *image, int x, int y, int depth) {
-#warning "FIXME: cast"
- CamoramaFilterThreshold* self = (CamoramaFilterThreshold*)filter;
+camorama_filter_threshold_filter(void * filter, guchar *image, int x, int y, int depth) {
+ CamoramaFilterThreshold* self = filter;
int i;
for (i = 0; i < x * y; i++) {
if ((image[0] + image[1] + image[2]) > (self->threshold * 3)) {
@@ -247,9 +243,8 @@ camorama_filter_threshold_channel_init(CamoramaFilterThresholdChannel* self) {
}
static void
-camorama_filter_threshold_channel_filter(CamoramaFilter* filter, unsigned char *image, int x, int y, int depth) {
-#warning "FIXME: cast"
- CamoramaFilterThresholdChannel* self = (CamoramaFilterThresholdChannel*)filter;
+camorama_filter_threshold_channel_filter(void *filter, unsigned char *image, int x, int y, int depth) {
+ CamoramaFilterThresholdChannel* self = filter;
int i;
for (i = 0; i < x * y; i++) {
if (image[0] > self->threshold) {
@@ -287,14 +282,13 @@ static void
camorama_filter_wacky_init(CamoramaFilterWacky* self) {}
static void
-camorama_filter_wacky_filter(CamoramaFilter* filter, unsigned char *image, int x, int y, int depth) {
+camorama_filter_wacky_filter(void *filter, unsigned char *image, int x, int y, int depth) {
int i;
int neighbours;
int total;
- unsigned char *image2, *image3;
+ unsigned char *image2;
image2 = (unsigned char *) malloc (sizeof (unsigned char) * x * y * depth);
memcpy (image2, image, x * y * depth);
- image3 = image2;
for (i = 0; i < x * y; i++) {
total = 0;
@@ -360,7 +354,7 @@ static void
camorama_filter_smooth_init(CamoramaFilterSmooth* self) {}
static void
-camorama_filter_smooth_filter(CamoramaFilter* filter, guchar *image, int x, int y, int depth) {
+camorama_filter_smooth_filter(void * filter, guchar *image, int x, int y, int depth) {
int i;
int neighbours;
int total0, total1, total2;
@@ -461,7 +455,7 @@ static void
camorama_filter_mono_init(CamoramaFilterMono* self) {}
static void
-camorama_filter_mono_filter(CamoramaFilter* filter, unsigned char *image, int x, int y, int depth) {
+camorama_filter_mono_filter(void *filter, unsigned char *image, int x, int y, int depth) {
int i;
int total, avg;
@@ -492,7 +486,7 @@ static void
camorama_filter_mono_weight_init(CamoramaFilterMonoWeight* self) {}
static void
-camorama_filter_mono_weight_filter(CamoramaFilter* filter, unsigned char *image, int x, int y, int depth) {
+camorama_filter_mono_weight_filter(void *filter, unsigned char *image, int x, int y, int depth) {
int i;
int avg;
for (i = 0; i < x * y; i++) {
@@ -523,7 +517,7 @@ camorama_filter_sobel_init(CamoramaFilterSobel* self) {}
/* fix this at some point, very slow */
static void
-camorama_filter_sobel_filter(CamoramaFilter* filter, unsigned char *image, int x, int y, int depth) {
+camorama_filter_sobel_filter(void *filter, unsigned char *image, int x, int y, int depth) {
int i, j, grad[3];
int deltaX[3], deltaY[3];
int width = x * 3;
diff --git a/src/filter.h b/src/filter.h
index 24b526d..d06d44d 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -76,7 +76,7 @@ struct _CamoramaFilterClass {
gchar const* name;
- void (*filter) (CamoramaFilter* self,
+ void (*filter) (void * self,
guchar * image,
gint width,
gint height,
diff --git a/src/main.c b/src/main.c
index 21b96ad..d8bfcec 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,6 +21,10 @@ static int half = 0, use_read = 0, buggery = 0;
static gchar *poopoo = NULL;
static int x = -1, y = -1;
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
+
static GOptionEntry options[] = {
{"version", 'V', 0, G_OPTION_ARG_NONE, &ver,
N_("show version and exit"), NULL},
@@ -42,6 +46,7 @@ static GOptionEntry options[] = {
N_("use read() rather than mmap()"), NULL},
{ NULL }
};
+#pragma GCC diagnostic pop
int
main(int argc, char *argv[]) {
@@ -49,6 +54,7 @@ main(int argc, char *argv[]) {
Display *display;
Screen *screen_num;
GConfClient *gc;
+ GtkWidget *widget;
unsigned int bufsize;
GError *error = NULL;
@@ -134,6 +140,11 @@ main(int argc, char *argv[]) {
cam->video_dev = g_strdup (poopoo);
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
+ cam->date_format = "%Y-%m-%d %H:%M:%S";
+#pragma GCC diagnostic pop
+
cam->pixdir = g_strdup (gconf_client_get_string (cam->gc, KEY1, NULL));
cam->capturefile =
g_strdup (gconf_client_get_string (cam->gc, KEY2, NULL));
@@ -145,7 +156,6 @@ main(int argc, char *argv[]) {
cam->rsavetype = gconf_client_get_int (cam->gc, KEY10, NULL);
cam->ts_string =
g_strdup (gconf_client_get_string (cam->gc, KEY16, NULL));
- cam->date_format = "%Y-%m-%d %H:%M:%S";
cam->timestamp = gconf_client_get_bool (cam->gc, KEY4, NULL);
cam->rtimestamp = gconf_client_get_bool (cam->gc, KEY11, NULL);
@@ -160,7 +170,6 @@ main(int argc, char *argv[]) {
cam->show_adjustments = gconf_client_get_bool (cam->gc, KEY22, NULL);
cam->show_effects = gconf_client_get_bool (cam->gc, KEY23, NULL);
-
/* get desktop depth */
display = (Display *) gdk_x11_get_default_xdisplay ();
screen_num = xlib_rgb_get_screen ();
@@ -221,7 +230,7 @@ main(int argc, char *argv[]) {
* gtk_widget_show_all (GTK_WIDGET (tray_icon)); */
load_interface (cam);
- GtkWidget *widget = GTK_WIDGET (gtk_builder_get_object (cam->xml, "da"));
+ widget = GTK_WIDGET (gtk_builder_get_object (cam->xml, "da"));
gtk_widget_show (widget);
cam->idle_id = g_idle_add ((GSourceFunc) pt2Function, (gpointer) cam);
diff --git a/src/v4l.c b/src/v4l.c
index d7af8aa..31d6f0f 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -33,9 +33,9 @@ void print_cam(cam_t *cam){
printf("timestamp = %s\n\n",cam->ts_string);
}
-static void insert_resolution(cam_t *cam, int x, int y)
+static void insert_resolution(cam_t *cam, unsigned int x, unsigned int y)
{
- int i;
+ unsigned int i;
try_set_win_info(cam, &x, &y);
for (i = 0; i < cam->n_res; i++) {
@@ -68,7 +68,8 @@ void get_supported_resolutions(cam_t *cam)
{
struct v4l2_fmtdesc fmt;
struct v4l2_frmsizeenum frmsize;
- int i, x, y;
+ int i;
+ unsigned int x, y;
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -337,7 +338,7 @@ void get_win_info(cam_t *cam)
}
}
-void try_set_win_info(cam_t *cam, int *x, int *y)
+void try_set_win_info(cam_t *cam, unsigned int *x, unsigned int *y)
{
struct v4l2_format fmt;
@@ -488,11 +489,12 @@ void start_streaming(cam_t *cam)
}
}
-void capture_buffers(cam_t *cam, unsigned char *outbuf, int len)
+void capture_buffers(cam_t *cam, unsigned char *outbuf, unsigned int len)
{
char *msg;
unsigned char *inbuf;
- int r, y;
+ int r;
+ unsigned int y;
fd_set fds;
struct v4l2_buffer buf;
struct timeval tv;
diff --git a/src/v4l.h b/src/v4l.h
index c1180f5..337f6ca 100644
--- a/src/v4l.h
+++ b/src/v4l.h
@@ -44,13 +44,12 @@ struct buffer_start_len {
};
struct resolutions {
- int x, y;
+ unsigned int x, y;
};
typedef struct camera {
int dev;
- int width;
- int height;
+ unsigned int width, height;
int bpp;
int desk_depth;
CamoImageSize size;
@@ -59,9 +58,9 @@ typedef struct camera {
unsigned int pixformat;
int frame_number;
- int min_width, min_height, max_width, max_height;
+ unsigned int min_width, min_height, max_width, max_height;
- int n_res;
+ unsigned int n_res;
struct resolutions *res;
char *video_dev;
@@ -100,13 +99,13 @@ typedef struct camera {
void camera_cap (cam_t *);
void print_cam (cam_t *);
-void try_set_win_info(cam_t *cam, int *x, int *y);
+void try_set_win_info(cam_t *cam, unsigned int *x, unsigned int *y);
void set_win_info (cam_t *cam);
void get_pic_info (cam_t *);
void get_win_info (cam_t *);
void get_supported_resolutions(cam_t *cam);
void start_streaming(cam_t *cam);
-void capture_buffers(cam_t *cam, unsigned char *outbuf, int len);
+void capture_buffers(cam_t *cam, unsigned char *outbuf, unsigned int len);
void stop_streaming(cam_t *cam);
#endif /* !CAMORAMA_V4L_H */

Privacy Policy