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: 86488 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 43C5E3858C78 for ; Tue, 27 Feb 2024 22:23:43 +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+patchwork=sourceware.org@gcc.gnu.org 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 ())); }