Skip to main content
added 1 character in body
Source Link
chux
  • 36.5k
  • 2
  • 43
  • 97

Save time. enable Enable all compiler warnings

This savesaves OP and reviewers time.

Save time. enable all compiler warnings

This save OP and reviewers time.

Save time. Enable all compiler warnings

This saves OP and reviewers time.

deleted 51 characters in body
Source Link
chux
  • 36.5k
  • 2
  • 43
  • 97

Rather than only test for 0, test if not all read. Unclear the roll of ch in the send_to_char().

Rather than only test for 0, test if not all read. Unclear the roll of ch in the send_to_char().

Rather than only test for 0, test if not all read.

added 170 characters in body
Source Link
chux
  • 36.5k
  • 2
  • 43
  • 97
// if (!strlen(helpfile))
if (helpfile[0] == '\0')
  return FALSE;

is...() expect unsignedunsigned char values (or EOF)

isspace(buf[len-1]) is UB when buf[len-1] < 0. Better as ((unsigned char *buf*)buf)[len-1] or the like.

Rather than only test for 0, test if not all read. Unclear the roll of ch herein the send_to_char().

size_t nread = fread(buf, 1, flen, fhelp);
...
//if (!nread) {
//        send_to_char("Unable to read helpfiles list.\r\n", ch);
if (nread != flen) {
        send_to_char("Unable to read entire helpfiles list.\r\n", ch);
 
Maybe add file name and length read to message?

Maybe add file name and length read to message?

Unneeded code

if (len > 0 && buf[len-1] == '\n') buf[--len] = '\0'; not needed when followed by while (len > 0 && isspace(buf[len-1])) buf[--len] = '\0';

if (!strlen(helpfile))
if (helpfile[0] == '\0')
  return FALSE;

is...() expect unsigned values (or EOF)

isspace(buf[len-1]) is UB when buf[len-1] < 0. Better as (unsigned char *buf)[len-1].

Rather than only test for 0, test if not all read. Unclear the roll of ch here.

size_t nread = fread(buf, 1, flen, fhelp);
...
//if (!nread) {
//        send_to_char("Unable to read helpfiles list.\r\n", ch);
if (nread != flen) {
        send_to_char("Unable to read entire helpfiles list.\r\n");
 
Maybe add file name and length read to message?
// if (!strlen(helpfile))
if (helpfile[0] == '\0')
  return FALSE;

is...() expect unsigned char values (or EOF)

isspace(buf[len-1]) is UB when buf[len-1] < 0. Better as ((unsigned char *)buf)[len-1] or the like.

Rather than only test for 0, test if not all read. Unclear the roll of ch in the send_to_char().

size_t nread = fread(buf, 1, flen, fhelp);
...
//if (!nread) {
//        send_to_char("Unable to read helpfiles list.\r\n", ch);
if (nread != flen) {
        send_to_char("Unable to read entire helpfiles list.\r\n", ch);

Maybe add file name and length read to message?

Unneeded code

if (len > 0 && buf[len-1] == '\n') buf[--len] = '\0'; not needed when followed by while (len > 0 && isspace(buf[len-1])) buf[--len] = '\0';

Source Link
chux
  • 36.5k
  • 2
  • 43
  • 97
Loading