Skip to content
  • Ævar Arnfjörð Bjarmason's avatar
    Fix a bitwise negation assignment issue spotted by Sun Studio · 952fba9c
    Ævar Arnfjörð Bjarmason authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Change direct and indirect assignments of the bitwise negation of 0 to
    uint32_t variables to have a "U" suffix. I.e. ~0U instead of ~0. This
    eliminates warnings under Sun Studio 12 Update 1:
    
        "vcs-svn/string_pool.c", line 11: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)
        "vcs-svn/string_pool.c", line 81: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)
        "vcs-svn/repo_tree.c", line 112: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)
        "vcs-svn/repo_tree.c", line 112: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)
        "test-treap.c", line 34: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)
    
    The semantics are still the same as demonstrated by this program:
    
        $ cat test.c && make test && ./test
        #include <stdio.h>
        #include <stdint.h>
    
        int main(void)
        {
            uint32_t foo = ~0;
            uint32_t bar = ~0U;
    
            printf("foo = <%u> bar = <%u>\n", foo, bar);
    
            return 0;
        }
        cc     test.c   -o test
        "test.c", line 5: warning: initializer will be sign-extended: -1
        foo = <4294967295> bar = <4294967295>
    
    Signed-off-by: default avatarÆvar Arnfjörð Bjarmason <avarab@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    952fba9c