bugGNU roff - Bugs: bug #51483, [PATCH] gcc warns of misleading...

 
 

bug #51483: [PATCH] gcc warns of misleading indentation

Submitter:  Bjarni Ingi Gislason <bjarniig>
Submitted:  Sun 16 Jul 2017 08:59:54 PM UTC
   
 
Category:  General Severity:  3 - Normal
Item Group:  Build/Installation Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.22.4
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 15 Jun 2022 02:47:12 PM UTC, comment #1: 


commit 21b07d7b641d4572c4916d04069e18c8feba91cc
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sat Nov 11 17:23:32 2017 -0500

    src: Resolve -Wmisleading-indentation warnings.

    Fix bug https://savannah.gnu.org/bugs/?51483.

    * src/devices/grolbp/lbp.cpp (lbp_printer::setfillmode): No change in
      operation; code was wrongly indented but appeared to do what was
      intended.

    * src/roff/troff/mtsm.cpp (mtsm::push_state, mtsm::pop_state): Only
      flush standard error if we just wrote to it, not unconditionally.

    Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>


G. Branden Robinson <gbranden>
Group administrator
Sun 16 Jul 2017 08:59:54 PM UTC, original submission:  


  In the first case the "fill_mode = mode" looks like it belongs to the else-clause (same indention) but I don't see the logic in that.

  In the second case the else clause contains two statements in the same line.


  Warning from the gcc compiler:

1) src/devices/grolbp/lbp.cpp:

In member function 'void lbp_printer::setfillmode(int)':

390:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
     else
     ^~~~
393:7: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'else'
       fill_mode = mode;
       ^~~~~~~~~

2) src/roff/troff/mtsm.cpp:

In member function 'void mtsm::push_state(statem*)':
377:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (debug_state)
     ^~
378:63: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
       fprintf(stderr, "--> state %d pushed\n", n->issue_no) ; fflush(stderr);
                                                               ^~~~~~
In member function 'void mtsm::pop_state()':
388:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (debug_state)
     ^~
389:47: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
       fprintf(stderr, "--> state popped\n") ; fflush(stderr);
                                               ^~~~~~



From 627423b8b18f6e0412632a24df83174a260b2259 Mon Sep 17 00:00:00 2001
From: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Date: Sun, 16 Jul 2017 20:43:58 +0000
Subject: [PATCH]   Warning from the gcc compiler:

1) src/devices/grolbp/lbp.cpp:

In member function 'void lbp_printer::setfillmode(int)':

390:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
     else
     ^~~~
393:7: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'else'
       fill_mode = mode;
       ^~~~~~~~~

2) src/roff/troff/mtsm.cpp:

In member function 'void mtsm::push_state(statem*)':
377:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (debug_state)
     ^~
378:63: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
       fprintf(stderr, "--> state %d pushed\n", n->issue_no) ; fflush(stderr);
                                                               ^~~~~~
In member function 'void mtsm::pop_state()':
388:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (debug_state)
     ^~
389:47: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
       fprintf(stderr, "--> state popped\n") ; fflush(stderr);
                                               ^~~~~~

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 src/devices/grolbp/lbp.cpp | 5 +++--
 src/roff/troff/mtsm.cpp    | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp
index fbd1bbf5..aaa03886 100644
--- a/src/devices/grolbp/lbp.cpp
+++ b/src/devices/grolbp/lbp.cpp
@@ -387,10 +387,11 @@ inline void lbp_printer::setfillmode(int mode)
   if (mode != fill_mode) {
     if (mode != 1)
       vdmsetfillmode(mode, 1, 0);
-    else
+    else {
       vdmsetfillmode(mode, 1, 1);        // To get black we must use white
                                         // inverted
-      fill_mode = mode;
+    }
+    fill_mode = mode;
   }
 }

diff --git a/src/roff/troff/mtsm.cpp b/src/roff/troff/mtsm.cpp
index 0fd2d33f..dcf31ad9 100644
--- a/src/roff/troff/mtsm.cpp
+++ b/src/roff/troff/mtsm.cpp
@@ -374,8 +374,9 @@ void mtsm::push_state(statem *n)
 {
   if (is_html) {
 #if defined(DEBUGGING)
-    if (debug_state)
+    if (debug_state) {
       fprintf(stderr, "--> state %d pushed\n", n->issue_no) ; fflush(stderr);
+    }
 #endif
     sp = new stack(n, sp);
   }
@@ -385,8 +386,9 @@ void mtsm::pop_state()
 {
   if (is_html) {
 #if defined(DEBUGGING)
-    if (debug_state)
+    if (debug_state) {
       fprintf(stderr, "--> state popped\n") ; fflush(stderr);
+    }
 #endif
     if (sp == 0)
       fatal("empty state machine stack");
--
2.13.2


Bjarni Ingi Gislason <bjarniig>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bgarrigues (Updated the item)
  • -email is unavailable- added by gbranden (Updated the item)
  • -email is unavailable- added by bjarniig (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-06-15 gbranden CategoryNone General
        Planned ReleaseNone 1.22.4
    2018-07-02 bgarrigues Open/ClosedOpen Closed
    2017-11-11 gbranden StatusIn Progress Fixed
    2017-11-10 gbranden Summary[PATCH] Warning from the gcc compiler [PATCH] gcc warns of misleading indentation
    2017-11-10 gbranden StatusNone In Progress
        Assigned toNone gbranden
    2017-11-03 gbranden Item GroupNone Build/Installation

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code