From 56ec4e86585e0fe0b4fe83bdbfa20aa1e244a9e0 Mon Sep 17 00:00:00 2001 From: Jacques Garrigue Date: Thu, 23 Jan 2020 15:32:02 +0100 Subject: [PATCH] fix C compilation warnings + typo in sourceview3 --- CHANGES.md | 4 +++- src-sourceview3/ml_gtksourceview3.c | 4 ++-- src/ml_gdk.c | 2 +- src/ml_gdkpixbuf.c | 6 +++--- src/ml_glib.c | 20 ++++++++++---------- src/ml_gtk.c | 8 ++++---- src/ml_gtkstock.c | 4 ++-- src/ml_gtktree.c | 4 ++-- src/wrappers.c | 2 +- src/wrappers.h | 4 ++++ 10 files changed, 32 insertions(+), 26 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 489c0e0a..e0833bd5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,7 +3,9 @@ LablGTK changes log ## In Lablgtk-3.1.0 2020.01.23 [Jacques] - * headers changed again in ocaml 4.10.beta2 + * headers changed again in ocaml 4.10.0beta2 + * fix C compilation warnings + * fix SourceMarkAttributes.new_attribute 2020.01.14 [Jacques] * remove GtkDialog#has_separator property (report by Thomas Leonard, #68) diff --git a/src-sourceview3/ml_gtksourceview3.c b/src-sourceview3/ml_gtksourceview3.c index 8f5d0f1e..379076aa 100644 --- a/src-sourceview3/ml_gtksourceview3.c +++ b/src-sourceview3/ml_gtksourceview3.c @@ -76,7 +76,7 @@ CAMLprim value ml_gtk_source_view_init(value unit) static gpointer string_val(value v) { - return String_val(v); + return Bytes_val(v); } GSList *ml_gslist_of_string_list(value list) @@ -546,7 +546,7 @@ ML_2 (gtk_source_mark_prev, GtkSourceMark_val, String_option_val, Val_option_Gtk // SourceMarkAttributes -ML_0(gtk_source_mark_attributes_new,GtkSourceMarkAttributes_val) +ML_0(gtk_source_mark_attributes_new,Val_GtkSourceMarkAttributes) ML_4(gtk_source_view_set_mark_attributes, GtkSourceView_val, String_val, GtkSourceMarkAttributes_val, Int_val, Unit) diff --git a/src/ml_gdk.c b/src/ml_gdk.c index de49b597..bc5ab60a 100644 --- a/src/ml_gdk.c +++ b/src/ml_gdk.c @@ -390,7 +390,7 @@ CAMLprim value copy_xdata (gint format, void *xdata, gulong nitems) switch (format) { case 8: data = alloc_string (nitems); - memcpy (String_val(data), xdata, sizeof(char) * nitems); + memcpy (Bytes_val(data), xdata, sizeof(char) * nitems); tag = MLTAG_BYTES; break; case 16: diff --git a/src/ml_gdkpixbuf.c b/src/ml_gdkpixbuf.c index 7922a76b..d36cb4fa 100644 --- a/src/ml_gdkpixbuf.c +++ b/src/ml_gdkpixbuf.c @@ -262,9 +262,9 @@ convert_gdk_pixbuf_options (value options, char ***opt_k, char ***opt_v, gboolea { char *s; value pair = Field(cell, 0); - s = String_val(Field(pair, 0)); + s = Bytes_val(Field(pair, 0)); *opt_k[i] = copy ? g_strdup (s) : s; - s = String_val(Field(pair, 1)); + s = Bytes_val(Field(pair, 1)); *opt_v[i] = copy ? g_strdup (s) : s; cell = Field(cell, 1); } @@ -303,7 +303,7 @@ ml_gdkpixbuf_savefunc (const gchar *buf, gsize count, GError **error, gpointer d value *cb = data; value res, s; s = alloc_string (count); - memcpy (String_val(s), buf, count); + memcpy (Bytes_val(s), buf, count); res = callback_exn (*cb, s); if (Is_exception_result (res)) { diff --git a/src/ml_glib.c b/src/ml_glib.c index 32044602..070cd66d 100644 --- a/src/ml_glib.c +++ b/src/ml_glib.c @@ -87,7 +87,7 @@ CAMLprim value copy_string_g_free (char *str) static void ml_raise_glib (const char *errmsg) { - static value * exn = NULL; + static const value * exn = NULL; if (exn == NULL) exn = caml_named_value ("gerror"); raise_with_string (*exn, (char*)errmsg); @@ -133,7 +133,7 @@ static GSList *exn_map; struct exn_data { GQuark domain; char *caml_exn_name; - value *caml_exn; + const value *caml_exn; }; CAMLprim void ml_register_exn_map (GQuark domain, char *caml_name) @@ -145,7 +145,7 @@ CAMLprim void ml_register_exn_map (GQuark domain, char *caml_name) exn_map = g_slist_prepend (exn_map, exn_data); } -static value *lookup_exn_map (GQuark domain) +static const value *lookup_exn_map (GQuark domain) { GSList *l = exn_map; struct exn_data *exn_data; @@ -160,8 +160,8 @@ static value *lookup_exn_map (GQuark domain) return NULL; } -static void ml_raise_gerror_exn(GError *, value *) Noreturn; -static void ml_raise_gerror_exn(GError *err, value *exn) +static void ml_raise_gerror_exn(GError *, const value *) Noreturn; +static void ml_raise_gerror_exn(GError *err, const value *exn) { CAMLparam0(); CAMLlocal2(b, msg); @@ -178,7 +178,7 @@ static void ml_raise_gerror_exn(GError *err, value *exn) static void ml_raise_generic_gerror (GError *) Noreturn; static void ml_raise_generic_gerror (GError *err) { - static value *exn; + static const value *exn; value msg; if (exn == NULL) { exn = caml_named_value ("gerror"); @@ -192,7 +192,7 @@ static void ml_raise_generic_gerror (GError *err) CAMLprim void ml_raise_gerror(GError *err) { - value *caml_exn; + const value *caml_exn; g_assert (err); caml_exn = lookup_exn_map (err->domain); if (caml_exn) @@ -368,7 +368,7 @@ CAMLprim value ml_g_io_channel_read(value io, value str, value offset, { gsize read; switch (g_io_channel_read(GIOChannel_val(io), - String_val(str) + Int_val(offset), + Bytes_val(str) + Int_val(offset), Int_val(count), &read)) { case G_IO_ERROR_NONE: @@ -390,7 +390,7 @@ CAMLprim value ml_g_io_channel_read_chars(value io, value str, value offset, GError *err = NULL; GIOStatus result = g_io_channel_read_chars(GIOChannel_val(io), - String_val(str) + Int_val(offset), + Bytes_val(str) + Int_val(offset), Int_val(count), &read, &err); @@ -463,7 +463,7 @@ caml_copy_string_len_and_free (char *str, size_t len) value v; g_assert (str != NULL); v = alloc_string (len); - memcpy (String_val(v), str, len); + memcpy (Bytes_val(v), str, len); g_free (str); return v; } diff --git a/src/ml_gtk.c b/src/ml_gtk.c index 3ce98f4b..e0080d05 100644 --- a/src/ml_gtk.c +++ b/src/ml_gtk.c @@ -46,7 +46,7 @@ void ml_raise_gtk (const char *errmsg) { - static value * exn = NULL; + static const value * exn = NULL; if (exn == NULL) exn = caml_named_value ("gtkerror"); raise_with_string (*exn, (char*)errmsg); @@ -384,7 +384,7 @@ CAMLprim value ml_gtk_widget_style_get_property (value w, value n) CAMLparam2 (w, n); CAMLlocal1 (ret); GtkWidget *widget = GtkWidget_val (w); - gchar *name = String_val (n); + gchar *name = Bytes_val (n); GParamSpec * pspec; pspec = gtk_widget_class_find_style_property (GTK_WIDGET_GET_CLASS (widget), name); @@ -435,7 +435,7 @@ CAMLprim value ml_gtk_drag_dest_set (value w, value f, value t, value a) alloc (Wosize_asize(n_targets * sizeof(GtkTargetEntry)), Abstract_tag); for (i=0; i young_start) +#ifndef Bytes_val +#define Bytes_val String_val +#endif + CAMLexport value copy_memblock_indirected (void *src, asize_t size); value alloc_memblock_indirected (asize_t size); CAMLexport value ml_alloc_custom(struct custom_operations * ops,