[committed] libcpp: Make static checkers happy about makeuname2c [PR106778]

Message ID Yw8gtCMf2TMmnl6r@tucnak
State New, archived
Headers
Series [committed] libcpp: Make static checkers happy about makeuname2c [PR106778] |

Commit Message

Jakub Jelinek Aug. 31, 2022, 8:49 a.m. UTC
  Hi!

The assertion ensures that we point within the image and at a byte
we haven't touched yet (or at least that it isn't the first byte
of an already stored tree), some static checker was unhappy about
first checking that it is zero and only afterwards checking that it
is within bounds.

Obviously nothing changes on the generated uname2c.h and while I've
bootstrapped/regtested it on x86_64-linux and i686-linux, the generator
is only used when built and run by hand (note, when updating to a newer
Unicode it won't be just a matter of rerunning it against newer files,
but one needs to update the generated_ranges according to Table 4-8
in the sources too).

Committed to trunk as obvious.

2022-08-31  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/106778
	* makeuname2c.cc (write_nodes): Reverse order of && operands in
	assert.


	Jakub
  

Patch

--- libcpp/makeuname2c.cc.jj	2022-08-26 09:24:12.122615517 +0200
+++ libcpp/makeuname2c.cc	2022-08-30 17:28:20.171052344 +0200
@@ -451,7 +451,7 @@  write_nodes (struct node *n, size_t off)
 {
   for (; n; n = n->sibling)
     {
-      assert (tree[off] == 0 && off < tree_size);
+      assert (off < tree_size && tree[off] == 0);
       if (n->key_len > 1)
 	{
 	  assert (n->key_len < 64);