From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#35062: [PATCH v3 2/3] constify a bit of xterm.c Date: Sun, 7 Apr 2019 05:13:30 +0300 Message-ID: <20190407021331.948-2-Hi-Angel@yandex.ru> References: <20190407021331.948-1-Hi-Angel@yandex.ru> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="69150"; mail-complaints-to="usenet@blaine.gmane.org" To: 35062@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 07 04:14:40 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCxKS-000Hu7-10 for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Apr 2019 04:14:40 +0200 Original-Received: from localhost ([127.0.0.1]:33151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCxKR-0005SC-1l for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Apr 2019 22:14:39 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCxJs-0005BL-1y for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 22:14:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hCxJq-00048Y-SS for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 22:14:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34095) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hCxJq-00048R-Kb for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 22:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hCxJq-0005gM-Eb for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 22:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Apr 2019 02:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35062 X-GNU-PR-Package: emacs Original-Received: via spool by 35062-submit@debbugs.gnu.org id=B35062.155460322821791 (code B ref 35062); Sun, 07 Apr 2019 02:14:02 +0000 Original-Received: (at 35062) by debbugs.gnu.org; 7 Apr 2019 02:13:48 +0000 Original-Received: from localhost ([127.0.0.1]:47635 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCxJb-0005fO-Mx for submit@debbugs.gnu.org; Sat, 06 Apr 2019 22:13:48 -0400 Original-Received: from forward103p.mail.yandex.net ([77.88.28.106]:47596) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCxJZ-0005ev-Ag for 35062@debbugs.gnu.org; Sat, 06 Apr 2019 22:13:46 -0400 Original-Received: from mxback14g.mail.yandex.net (mxback14g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:93]) by forward103p.mail.yandex.net (Yandex) with ESMTP id E2DC618C086D for <35062@debbugs.gnu.org>; Sun, 7 Apr 2019 05:13:38 +0300 (MSK) Original-Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback14g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Zlvv0IdMEi-DcS4lFoC; Sun, 07 Apr 2019 05:13:38 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1554603218; bh=0WZfZThccs29DGj+HjpNdKhWzrwfhgj9z5PxXYaUEBI=; h=In-Reply-To:Subject:To:From:References:Date:Message-Id; b=hyAjjEeBcGVImKJMEgaXqOJjKfp4ztNsLpr62M8uHO2CyV5UKtv5zD1fmP8ifgI93 /7Ub+Gka3hsPB4gqnYg15cMUfI/dqdxpnPTdajtSuH/YGXxoZKC1qhsUbHt3RlYZSy 3K+iFJog/O30VdnS7DBKsYUVg4wSCnVLOvdwEMfk= Authentication-Results: mxback14g.mail.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id pCSJWT6WkI-Dci8ucO8; Sun, 07 Apr 2019 05:13:38 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190407021331.948-1-Hi-Angel@yandex.ru> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:157298 Archived-At: * src/xterm.c (x_cr_draw_image, x_update_begin, x_clear_under_internal_border, x_draw_fringe_bitmap, x_set_glyph_string_clipping, x_draw_glyph_string_background, x_draw_composite_glyph_string_foreground, x_send_scroll_bar_event): make code easier to follow by making explicit that some variables are immutable. (Bug#35062) --- v3: mention functions changed in commit messages, mention the bug number, and don't mention that it fixes a warning since intention of changes is clear either way. src/xterm.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index e8f1e576a38..8354ce00700 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -495,9 +495,9 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_surface_t *image, cairo_fill_preserve (cr); } - int orig_image_width = cairo_image_surface_get_width (image); + const int orig_image_width = cairo_image_surface_get_width (image); if (image_width == 0) image_width = orig_image_width; - int orig_image_height = cairo_image_surface_get_height (image); + const int orig_image_height = cairo_image_surface_get_height (image); if (image_height == 0) image_height = orig_image_height; cairo_pattern_t *pattern = cairo_pattern_create_for_surface (image); @@ -1006,7 +1006,7 @@ x_update_begin (struct frame *f) if (FRAME_GTK_WIDGET (f)) { GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f)); - int scale = xg_get_scale (f); + const int scale = xg_get_scale (f); width = scale * gdk_window_get_width (w); height = scale * gdk_window_get_height (w); } @@ -1300,15 +1300,15 @@ x_clear_under_internal_border (struct frame *f) { if (FRAME_INTERNAL_BORDER_WIDTH (f) > 0) { - int border = FRAME_INTERNAL_BORDER_WIDTH (f); - int width = FRAME_PIXEL_WIDTH (f); - int height = FRAME_PIXEL_HEIGHT (f); + const int border = FRAME_INTERNAL_BORDER_WIDTH (f); + const int width = FRAME_PIXEL_WIDTH (f); + const int height = FRAME_PIXEL_HEIGHT (f); #ifdef USE_GTK - int margin = 0; + const int margin = 0; #else - int margin = FRAME_TOP_MARGIN_HEIGHT (f); + const int margin = FRAME_TOP_MARGIN_HEIGHT (f); #endif - int face_id = + const int face_id = !NILP (Vface_remapping_alist) ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID) : INTERNAL_BORDER_FACE_ID; @@ -1455,7 +1455,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring Drawable drawable = FRAME_X_DRAWABLE (f); char *bits; Pixmap pixmap, clipmask = (Pixmap) 0; - int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f)); + const int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f)); XGCValues gcv; if (p->wd > 8) @@ -1704,7 +1704,7 @@ static void x_set_glyph_string_clipping (struct glyph_string *s) { XRectangle *r = s->clip; - int n = get_glyph_string_clip_rects (s, r, 2); + const int n = get_glyph_string_clip_rects (s, r, 2); if (n > 0) x_set_clip_rectangles (s->f, s->gc, r, n); @@ -1797,7 +1797,7 @@ x_draw_glyph_string_background (struct glyph_string *s, bool force_p) shouldn't be drawn in the first place. */ if (!s->background_filled_p) { - int box_line_width = max (s->face->box_line_width, 0); + const int box_line_width = max (s->face->box_line_width, 0); if (s->stippled_p) { @@ -1908,15 +1908,15 @@ x_draw_composite_glyph_string_foreground (struct glyph_string *s) } else if (! s->first_glyph->u.cmp.automatic) { - int y = s->ybase; + const int y = s->ybase; for (i = 0, j = s->cmp_from; i < s->nchars; i++, j++) /* TAB in a composition means display glyphs with padding space on the left or right. */ if (COMPOSITION_GLYPH (s->cmp, j) != '\t') { - int xx = x + s->cmp->offsets[j * 2]; - int yy = y - s->cmp->offsets[j * 2 + 1]; + const int xx = x + s->cmp->offsets[j * 2]; + const int yy = y - s->cmp->offsets[j * 2 + 1]; font->driver->draw (s, j, j + 1, xx, yy, false); if (s->face->overstrike) @@ -5516,7 +5516,7 @@ x_send_scroll_bar_event (Lisp_Object window, enum scroll_bar_part part, struct frame *f = XFRAME (w->frame); intptr_t iw = (intptr_t) w; verify (INTPTR_WIDTH <= 64); - int sign_shift = INTPTR_WIDTH - 32; + const int sign_shift = INTPTR_WIDTH - 32; block_input (); -- 2.21.0