Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang Warnings #77

Open
a-p-jo opened this issue Feb 28, 2021 · 1 comment
Open

Clang Warnings #77

a-p-jo opened this issue Feb 28, 2021 · 1 comment

Comments

@a-p-jo
Copy link

a-p-jo commented Feb 28, 2021

kilo.c:71:8: warning: padding size of 'struct editorSyntax' with 4 bytes to alignment boundary [-Wpadded]
struct editorSyntax {
       ^
kilo.c:106:11: warning: padding struct 'struct editorConfig' with 4 bytes to align 'filename' [-Wpadded]
    char *filename; /* Currently open filename */

kilo.c:85:11: warning: padding struct 'struct erow' with 4 bytes to align 'chars' [-Wpadded]
    char *chars;        /* Row content. */
          ^
kilo.c:81:16: warning: padding size of 'struct erow' with 4 bytes to alignment boundary [-Wpadded]
typedef struct erow {

kilo.c:229:20: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
                ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kilo.c:231:20: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    raw.c_oflag &= ~(OPOST);

kilo.c:256:21: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
    while ((nread = read(fd,&c,1)) == 0);

kilo.c:383:36: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    row->hl = realloc(row->hl,row->rsize);
              ~~~~~~~         ~~~~~^~~~~
kilo.c:485:28: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                int klen = strlen(keywords[j]);

kilo.c:489:43: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
                if (!memcmp(p,keywords[j],klen) &&

kilo.c:541:26: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
            int patlen = strlen(s->filematch[i]);
                ~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~
kilo.c:573:31: warning: implicit conversion changes signedness: 'int' to 'unsigned int' [-Wsign-conversion]
    row->render = malloc(row->size + tabs*8 + nonprint*9 + 1);

kilo.c:594:50: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    E.row = realloc(E.row,sizeof(erow)*(E.numrows+1));
                                      ~ ~~~~~~~~~^~
kilo.c:596:64: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
        memmove(E.row+at+1,E.row+at,sizeof(E.row[0])*(E.numrows-at));

kilo.c:599:22: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    E.row[at].size = len;

kilo.c:627:63: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    memmove(E.row+at,E.row+at+1,sizeof(E.row[0])*(E.numrows-at-1));

kilo.c:648:22: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    p = buf = malloc(totlen);

kilo.c:667:57: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
        row->chars = realloc(row->chars,row->size+padlen+2);
                     ~~~~~~~            ~~~~~~~~~~~~~~~~^~
kilo.c:674:50: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
        row->chars = realloc(row->chars,row->size+2);
                     ~~~~~~~            ~~~~~~~~~^~
kilo.c:678:22: warning: implicit conversion loses integer precision: 'int' to 'char' [-Wimplicit-int-conversion]
    row->chars[at] = c;

kilo.c:685:42: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    row->chars = realloc(row->chars,row->size+len+1);

kilo.c:744:63: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
        editorInsertRow(filerow+1,row->chars+filecol,row->size-filecol);

kilo.c:771:65: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
        editorRowAppendString(&E.row[filerow-1],row->chars,row->size);

kilo.c:821:40: warning: implicit conversion changes signedness: 'ssize_t' (aka 'long') to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
        editorInsertRow(E.numrows,line,linelen);
        ~~~~~~~~~~~~~~~                ^~~~~~~
kilo.c:839:22: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
    if (write(fd,buf,len) != len) goto writeerr;
        ~~~~~        ^~~
kilo.c:868:38: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    char *new = realloc(ab->b,ab->len+len);
                ~~~~~~~       ~~~~~~~^~~~
kilo.c:860:8: warning: padding size of 'struct abuf' with 4 bytes to alignment boundary [-Wpadded]
struct abuf {
       ^
kilo.c:939:30: warning: declaration shadows a local variable [-Wshadow]
                        char buf[16];
                             ^
kilo.c:885:10: note: previous declaration is here
    char buf[32];
         ^
kilo.c:996:33: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
    write(STDOUT_FILENO,ab.b,ab.len);
    ~~~~~                    ~~~^~~
kilo.c:976:18: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    int msglen = strlen(E.statusmsg);
        ~~~~~~   ^~~~~~~~~~~~~~~~~~~
kilo.c:994:22: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    abAppend(&ab,buf,strlen(buf));
    ~~~~~~~~         ^~~~~~~~~~~
kilo.c:1005:47: warning: format string is not a string literal [-Wformat-nonliteral]
    vsnprintf(E.statusmsg,sizeof(E.statusmsg),fmt,ap);
                                              ^~~
kilo.c:1057:33: warning: implicit conversion loses integer precision: 'int' to 'char' [-Wimplicit-int-conversion]
                query[qlen++] = c;
                              ~ ^
kilo.c:1090:44: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
                    saved_hl = malloc(row->rsize);
                               ~~~~~~ ~~~~~^~~~~
kilo.c:1076:41: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                    match_offset = match-E.row[current].render;
                                 ~ ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kilo.c:1211:9: warning: 'break' will never be executed [-Wunreachable-code-break]
        break;
kilo.c:1307:12: warning: 'return' will never be executed [-Wunreachable-code-return]
    return 0;
@a-p-jo a-p-jo mentioned this issue Feb 28, 2021
@a-p-jo
Copy link
Author

a-p-jo commented Feb 28, 2021

Not to mention a lot of malloc()s and realloc()s are not checked !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant