Ticket #3693: mc-3693-edit.c-Cleanup-unsafe-loop-optimizations-compiler-wa.patch

File mc-3693-edit.c-Cleanup-unsafe-loop-optimizations-compiler-wa.patch, 1.3 KB (added by and, 6 years ago)
  • src/editor/edit.c

    From ff06d173de8cf6ae34ad7548d95c6cbc513fbc47 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Tue, 6 Dec 2016 09:58:11 +0000
    Subject: [PATCH] (edit.c) Cleanup unsafe-loop-optimizations compiler warning
    
    Found by GCC 6.2.0.
    
    edit.c: In function 'right_of_four_spaces':
    edit.c:1367:5: error: cannot optimize possibly infinite loops [-Werror=unsafe-loop-optimizations]
    
    edit.c: In function 'edit_backspace':
    edit.c:2682:5: error: cannot optimize possibly infinite loops [-Werror=unsafe-loop-optimizations]
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/editor/edit.c | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/src/editor/edit.c b/src/editor/edit.c
    index 56ef4b5..1b55c5c 100644
    a b right_of_four_spaces (WEdit * edit) 
    13641364{ 
    13651365    int i, ch = 0; 
    13661366 
    1367     for (i = 1; i <= HALF_TAB_SIZE; i++) 
     1367    for (i = HALF_TAB_SIZE; i > 0; i--) 
    13681368        ch |= edit_buffer_get_byte (&edit->buffer, edit->buffer.curs1 - i); 
    13691369 
    13701370    return (ch == ' ' && is_aligned_on_a_tab (edit)); 
    edit_backspace (WEdit * edit, gboolean byte_delete) 
    26782678    (void) byte_delete; 
    26792679#endif 
    26802680 
    2681     for (i = 1; i <= char_length; i++) 
     2681    for (i = char_length; i > 0; i--) 
    26822682    { 
    26832683        if (edit->mark1 >= edit->buffer.curs1) 
    26842684        {