hit9 / todo.c

Command line lightweight todo tool with readable storage , written in C.
BSD 2-Clause "Simplified" License
132 stars 23 forks source link

Condition always false #4

Closed nutsi closed 11 years ago

nutsi commented 11 years ago

Hi, in src/main.c at line 238 we can see the following code:

238 if (fwrite(ob->data, sizeof(uint8_t), ob->size, fp) < 0) { 239 printf("failed to write '%s'\n", todo_txt); 240 rt = RE_IO_ERROR; 241 }

fwrite returns an unsigned int (size_t), so this condition is broken. To fix it, just check correctly the number of caracteres who are writen. Like that: if (fwrite(ob->data, sizeof(uint8_t), ob->size, fp) != ob->size)

regards,

hit9 commented 11 years ago

fixed in commit https://github.com/hit9/todo.c/commit/9aeac63f1413aab9a52fe33c5f0300abe5318ef9