tweaks: replace sizeof(char) with 1, as that is assumed anyway

Since commit c848ec3d from three years ago, nano has assumed that
'char' is always a single byte.  So... elide the last occurrences
of sizeof(char), as they give a false impression of generality.
This commit is contained in:
Benno Schulenberg 2022-09-28 12:37:56 +02:00
parent ceb305a780
commit 119ec47072
2 changed files with 7 additions and 7 deletions

View File

@ -218,7 +218,7 @@ bool write_lockfile(const char *lockfilename, const char *filename, bool modifie
strncpy(&lockdata[108], filename, 768); strncpy(&lockdata[108], filename, 768);
lockdata[1007] = (modified) ? 0x55 : 0x00; lockdata[1007] = (modified) ? 0x55 : 0x00;
wroteamt = fwrite(lockdata, sizeof(char), LOCKSIZE, filestream); wroteamt = fwrite(lockdata, 1, LOCKSIZE, filestream);
free(lockdata); free(lockdata);
@ -990,7 +990,7 @@ void send_data(const linestruct *line, int fd)
while (line != NULL && (line->next != NULL || line->data[0] != '\0')) { while (line != NULL && (line->next != NULL || line->data[0] != '\0')) {
size_t length = recode_LF_to_NUL(line->data); size_t length = recode_LF_to_NUL(line->data);
if (fwrite(line->data, sizeof(char), length, tube) < length) if (fwrite(line->data, 1, length, tube) < length)
exit(5); exit(5);
if (line->next && putc('\n', tube) == EOF) if (line->next && putc('\n', tube) == EOF)
@ -1536,12 +1536,12 @@ int copy_file(FILE *inn, FILE *out, bool close_out)
int (*flush_out_fnc)(FILE *) = (close_out) ? fclose : fflush; int (*flush_out_fnc)(FILE *) = (close_out) ? fclose : fflush;
do { do {
charsread = fread(buf, sizeof(char), BUFSIZ, inn); charsread = fread(buf, 1, BUFSIZ, inn);
if (charsread == 0 && ferror(inn)) { if (charsread == 0 && ferror(inn)) {
retval = -1; retval = -1;
break; break;
} }
if (fwrite(buf, sizeof(char), charsread, out) < charsread) { if (fwrite(buf, 1, charsread, out) < charsread) {
retval = 2; retval = 2;
break; break;
} }
@ -1868,7 +1868,7 @@ bool write_file(const char *name, FILE *thefile, bool normal,
/* Decode LFs as the NULs that they are, before writing to disk. */ /* Decode LFs as the NULs that they are, before writing to disk. */
data_len = recode_LF_to_NUL(line->data); data_len = recode_LF_to_NUL(line->data);
wrote = fwrite(line->data, sizeof(char), data_len, thefile); wrote = fwrite(line->data, 1, data_len, thefile);
/* Re-encode any embedded NULs as LFs. */ /* Re-encode any embedded NULs as LFs. */
recode_NUL_to_LF(line->data, data_len); recode_NUL_to_LF(line->data, data_len);

View File

@ -307,7 +307,7 @@ bool write_list(const linestruct *head, FILE *histfile)
/* Decode 0x0A bytes as embedded NULs. */ /* Decode 0x0A bytes as embedded NULs. */
size_t length = recode_LF_to_NUL(item->data); size_t length = recode_LF_to_NUL(item->data);
if (fwrite(item->data, sizeof(char), length, histfile) < length) if (fwrite(item->data, 1, length, histfile) < length)
return FALSE; return FALSE;
if (putc('\n', histfile) == EOF) if (putc('\n', histfile) == EOF)
return FALSE; return FALSE;
@ -455,7 +455,7 @@ void save_poshistory(void)
/* Restore the terminating newline. */ /* Restore the terminating newline. */
path_and_place[length - 1] = '\n'; path_and_place[length - 1] = '\n';
if (fwrite(path_and_place, sizeof(char), length, histfile) < length) if (fwrite(path_and_place, 1, length, histfile) < length)
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno)); jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
free(path_and_place); free(path_and_place);