diff --git a/src/iso2022.c b/src/iso2022.c
index b81acc6..96092b5 100644
--- a/src/iso2022.c
+++ b/src/iso2022.c
@@ -779,7 +779,7 @@ #endif
 	state->codeset_changed = fn;
 	state->codeset_changed_data = data;
 	state->buffer = _vte_buffer_new();
-	if (state->conv == (VteConv) -1) {
+	if (state->conv == VTE_INVALID_CONV) {
 		g_warning(_("Unable to convert characters from %s to %s."),
 			  state->codeset, state->target_codeset);
 #ifdef VTE_DEBUG
@@ -790,7 +790,7 @@ #endif
 		state->codeset = state->utf8_codeset;
 		state->conv = _vte_conv_open(state->target_codeset,
 					     state->codeset);
-		if (state->conv == (VteConv) -1) {
+		if (state->conv == VTE_INVALID_CONV) {
 			g_error(_("Unable to convert characters from %s to %s."),
 				state->codeset, state->target_codeset);
 		}
@@ -802,7 +802,7 @@ void
 _vte_iso2022_state_free(struct _vte_iso2022_state *state)
 {
 	_vte_buffer_free(state->buffer);
-	if (state->conv != ((VteConv) -1)) {
+	if (state->conv != VTE_INVALID_CONV) {
 		_vte_conv_close(state->conv);
 	}
 	g_slice_free(struct _vte_iso2022_state, state);
@@ -824,12 +824,12 @@ #ifdef VTE_DEBUG
 	}
 #endif
 	conv = _vte_conv_open(state->target_codeset, codeset);
-	if (conv == (VteConv) -1) {
+	if (conv == VTE_INVALID_CONV) {
 		g_warning(_("Unable to convert characters from %s to %s."),
 			  codeset, state->target_codeset);
 		return;
 	}
-	if (state->conv != (VteConv) -1) {
+	if (state->conv != VTE_INVALID_CONV) {
 		_vte_conv_close(state->conv);
 	}
 	state->codeset = g_quark_to_string(g_quark_from_string(codeset));
diff --git a/src/trie.c b/src/trie.c
index 18015ca..8842479 100644
--- a/src/trie.c
+++ b/src/trie.c
@@ -504,7 +504,7 @@ _vte_trie_add(struct _vte_trie *trie, co
 	wpattern = wpattern_end = g_malloc0(wlength + 1);
 
 	conv = _vte_conv_open(VTE_CONV_GUNICHAR_TYPE, "UTF-8");
-	g_assert(conv != ((VteConv) -1));
+	g_assert(conv != VTE_INVALID_CONV);
 
 	tpattern = (char*)pattern;
 	_vte_conv(conv, &tpattern, &length, &wpattern_end, &wlength);
@@ -845,7 +845,7 @@ convert_mbstowcs(const char *i, size_t i
 	VteConv conv;
 	size_t outlen;
 	conv = _vte_conv_open(VTE_CONV_GUNICHAR_TYPE, "UTF-8");
-	g_assert(conv != ((VteConv) -1));
+	g_assert(conv != VTE_INVALID_CONV);
 
 	memset(o, 0, max_olen);
 	outlen = max_olen;
diff --git a/src/utf8echo.c b/src/utf8echo.c
index 1b12be2..5b20d0c 100644
--- a/src/utf8echo.c
+++ b/src/utf8echo.c
@@ -48,7 +48,7 @@ main(int argc, char **argv)
 	}
 
 	conv = _vte_conv_open("UTF-8", VTE_CONV_GUNICHAR_TYPE);
-	if (conv == ((VteConv) -1)) {
+	if (conv == VTE_INVALID_CONV) {
 		return 1;
 	}
 
diff --git a/src/vte.c b/src/vte.c
index 8929198..395d810 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -1586,12 +1586,12 @@ vte_terminal_set_encoding(VteTerminal *t
 
 	/* Open new conversions. */
 	conv = _vte_conv_open(codeset, "UTF-8");
-	if (conv == ((VteConv) -1)) {
+	if (conv == VTE_INVALID_CONV) {
 		g_warning(_("Unable to convert characters from %s to %s."),
 			  "UTF-8", codeset);
 		return;
 	}
-	if (terminal->pvt->outgoing_conv != (VteConv) -1) {
+	if (terminal->pvt->outgoing_conv != VTE_INVALID_CONV) {
 		_vte_conv_close(terminal->pvt->outgoing_conv);
 	}
 	terminal->pvt->outgoing_conv = conv;
@@ -3425,7 +3425,7 @@ vte_terminal_send(VteTerminal *terminal,
 		conv = terminal->pvt->outgoing_conv;
 	}
 	g_assert(conv != NULL);
-	g_assert(conv != ((VteConv) -1));
+	g_assert(conv != VTE_INVALID_CONV);
 
 	icount = length;
 	ibuf = (char *) data;
@@ -6725,7 +6725,7 @@ #endif
 	pvt->process_timeout = VTE_INVALID_SOURCE;
 	pvt->update_timeout = VTE_INVALID_SOURCE;
 	pvt->outgoing = _vte_buffer_new();
-	pvt->outgoing_conv = (VteConv) -1;
+	pvt->outgoing_conv = VTE_INVALID_CONV;
 	pvt->conv_buffer = _vte_buffer_new();
 	vte_terminal_set_encoding(terminal, NULL);
 	g_assert(terminal->pvt->encoding != NULL);
@@ -7179,10 +7179,10 @@ #endif
 		      TRUE);
 
 	/* Free conversion descriptors. */
-	if (terminal->pvt->outgoing_conv != ((VteConv) -1)) {
+	if (terminal->pvt->outgoing_conv != VTE_INVALID_CONV) {
 		_vte_conv_close(terminal->pvt->outgoing_conv);
+		terminal->pvt->outgoing_conv = VTE_INVALID_CONV;
 	}
-	terminal->pvt->outgoing_conv = ((VteConv) -1);
 
 	/* Stop listening for child-exited signals. */
 	if (terminal->pvt->pty_reaper != NULL) {
@@ -10398,7 +10398,7 @@ vte_terminal_set_word_chars(VteTerminal 
 	}
 	/* Convert the spec from UTF-8 to a string of gunichars . */
 	conv = _vte_conv_open(VTE_CONV_GUNICHAR_TYPE, "UTF-8");
-	if (conv == ((VteConv) -1)) {
+	if (conv == VTE_INVALID_CONV) {
 		/* Aaargh.  We're screwed. */
 		g_warning(_("_vte_conv_open() failed setting word characters"));
 		return;
diff --git a/src/vteconv.c b/src/vteconv.c
index f69025b..e09d23b 100644
--- a/src/vteconv.c
+++ b/src/vteconv.c
@@ -146,7 +146,7 @@ _vte_conv_open(const char *target, const
 	if (!utf8) {
 		conv = g_iconv_open(real_target, real_source);
 		if (conv == ((GIConv) -1)) {
-			return (VteConv) -1;
+			return VTE_INVALID_CONV;
 		}
 	}
 
@@ -178,7 +178,7 @@ gint
 _vte_conv_close(VteConv converter)
 {
 	g_assert(converter != NULL);
-	g_assert(converter != ((VteConv) -1));
+	g_assert(converter != VTE_INVALID_CONV);
 
 	/* Close the underlying descriptor, if there is one. */
 	if (converter->conv != NULL) {
@@ -208,7 +208,7 @@ _vte_conv(VteConv converter,
 	gsize in_converted, out_converted;
 
 	g_assert(converter != NULL);
-	g_assert(converter != ((VteConv) -1));
+	g_assert(converter != VTE_INVALID_CONV);
 
 	work_inbuf_start = work_inbuf_working = *inbuf;
 	work_outbuf_start = work_outbuf_working = *outbuf;
diff --git a/src/vteconv.h b/src/vteconv.h
index 9c70886..a790fba 100644
--- a/src/vteconv.h
+++ b/src/vteconv.h
@@ -27,6 +27,7 @@ #include <glib.h>
 G_BEGIN_DECLS
 
 #define VTE_CONV_GUNICHAR_TYPE "X-VTE-GUNICHAR"
+#define VTE_INVALID_CONV ((VteConv)-1)
 
 struct _VteConv;
 typedef struct _VteConv *VteConv;
diff --git a/src/vteseq.c b/src/vteseq.c
index eff303e..b6c8624 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -416,7 +416,7 @@ vte_sequence_handler_set_title_internal(
 			_vte_buffer_set_minimum_size(terminal->pvt->conv_buffer,
 						     outbuf_len);
 			outbuf = outbufptr = terminal->pvt->conv_buffer->bytes;
-			if (conv != ((VteConv) -1)) {
+			if (conv != VTE_INVALID_CONV) {
 				if (_vte_conv(conv, &inbuf, &inbuf_len,
 					      &outbuf, &outbuf_len) == -1) {
 #ifdef VTE_DEBUG
