From patchwork Tue Feb 27 22:23:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 207476 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2998242dyb; Tue, 27 Feb 2024 14:24:04 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWFXuD7q54wyMSeRqXV0RAl49vJ0rZpiCh7MLgvT891DaHOnSHvspwhugMhCTxu1s5zKW8FWKa0kDbld3WfAJHCCrjNBA== X-Google-Smtp-Source: AGHT+IEAblhnbiQ0J26Wm9z9clgbIcQUfb50jkii1eCmh3PcKg3yaXUN1Iv8/ITvfA3TTArrW5fZ X-Received: by 2002:ac8:5947:0:b0:42e:784a:b3c3 with SMTP id 7-20020ac85947000000b0042e784ab3c3mr12266342qtz.10.1709072644478; Tue, 27 Feb 2024 14:24:04 -0800 (PST) Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x17-20020a05620a0b5100b00787bc6aff27si8432739qkg.13.2024.02.27.14.24.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 14:24:04 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=U+c+vXDx; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 23B8A3858D33 for ; Tue, 27 Feb 2024 22:24:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A09E03858D33 for ; Tue, 27 Feb 2024 22:23:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A09E03858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A09E03858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709072594; cv=none; b=LzXc/7eMNGe4TtNesUtH1JJwfzD8SYxkDFmx15MxYbtzAj7IzTYqDw1uzd8hO6TXD6pSJm/5AXrsURV+jE21fR0KpmWMxAhooomNPKrGjN5KLfznLJ13GcH20TQQlGaOfFJUG7MJT/riJ2G6sOeHjwPNzL7Mh8CVL8UqM0J2PlI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709072594; c=relaxed/simple; bh=OpTbVwyzi3ddaGRnbFYGCty/ojHZdW3MbwLHUQuhVfk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=cRZiMU7G3oK9WrZF0wfmHnx/h4k0634knDkHBk8pEdmJZUgg/owYLRVFJMAYNxs6iCPefodrlV1p5mfRGtUY26z/BXulZH2W2izxKlUxp9p5RHQ5eFhXuijnbqA7QEQkt0urlrDOmOxebIITn8rNI5AjSrsq0eeQKaR5tzfeTEY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709072592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vQWDyoLo0JNjGJ1RU+h7YQzTe5NArm8DP0uTUvFULu8=; b=U+c+vXDxNUf6nKHfOGqw96dLqLhH/hhsJ9XGtoRb+s6XeIwB8mPspATZ8RQcAZkigvDpdH B1qiUHFIp3PJGo53sJwbxZB1OTdHlVL1qgy0edvzdtY7ZENuL6JA9SHe7aMXgZ0IUija2Z W2d1XnIK35vCu5/OP3PxlWOR+/Eqe9o= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-142-zpuY7CSUPwq_QWxTuYobZw-1; Tue, 27 Feb 2024 17:23:10 -0500 X-MC-Unique: zpuY7CSUPwq_QWxTuYobZw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 843F43812000 for ; Tue, 27 Feb 2024 22:23:10 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.9.138]) by smtp.corp.redhat.com (Postfix) with ESMTP id 567681CBC8; Tue, 27 Feb 2024 22:23:10 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed] analyzer: use correct format code for string literal indices [PR110483, PR111802] Date: Tue, 27 Feb 2024 17:23:09 -0500 Message-Id: <20240227222309.3519811-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792092557258993781 X-GMAIL-MSGID: 1792092557258993781 On e.g. gcc211 the use of "%li" with unsigned HOST_WIDE_INT led to this warning: ../../src/gcc/analyzer/access-diagram.cc: In member function ‘void ana::string_literal_spatial_item::add_column_for_byte(text_art::table&, const ana::bit_to_table_map&, text_art::style_manager&, ana::byte_offset_t, ana::byte_offset_t, int, int) const’: ../../src/gcc/analyzer/access-diagram.cc:1909:40: warning: format ‘%li’ expects argument of type ‘long int’, but argument 3 has type ‘long long unsigned int’ [-Wformat=] byte_idx_within_string.ulow ())); ^ and to all values being erroneously printed as "0". Fixed thusly. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Verified that this fixes the analyzer.exp=out-of-bounds-diagram*.c tests on gcc211 (sparc-sun-solaris2.11). Pushed to trunk as r14-9199-g939439a90f234f. gcc/analyzer/ChangeLog: PR analyzer/110483 PR analyzer/111802 * access-diagram.cc (string_literal_spatial_item::add_column_for_byte): Use %wu for printing unsigned HOST_WIDE_INT. Signed-off-by: David Malcolm --- gcc/analyzer/access-diagram.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/analyzer/access-diagram.cc b/gcc/analyzer/access-diagram.cc index 9555ee823931..24d203f9325a 100644 --- a/gcc/analyzer/access-diagram.cc +++ b/gcc/analyzer/access-diagram.cc @@ -1905,7 +1905,7 @@ private: const table::rect_t idx_table_rect = btm.get_table_rect (&m_string_reg, bytes, byte_idx_table_y, 1); t.set_cell_span (idx_table_rect, - fmt_styled_string (sm, "[%li]", + fmt_styled_string (sm, "[%wu]", byte_idx_within_string.ulow ())); }