Add some more missing y_nodiscard and fix compile errors

Signed-off-by: Gavin Howard <gavin@yzena.com>
master
Gavin D. Howard 2 months ago
parent ad37b89741
commit 2d968a817f
Signed by: gavin
GPG Key ID: F890265DD80E4E90

@ -119,18 +119,19 @@ main(void)
ystop = y_time_time_stop(ystart);
y_printf("When using overflow:\n\n");
(void) y_printf("When using overflow:\n\n");
y_printf("native sum: %d\nyc sum: %u\n", isum, ysum);
y_printf("native overflows: %d\nyc overflows: %u\n", ioflow, yoflow);
(void) y_printf("native sum: %d\nyc sum: %u\n", isum, ysum);
(void) y_printf("native overflows: %d\nyc overflows: %u\n", ioflow,
yoflow);
y_printf("native time: ");
(void) y_printf("native time: ");
(void) y_time_time_print_div(stop, NITERATIONS);
y_printf("\n");
(void) y_printf("\n");
y_printf("yc time: ");
(void) y_printf("yc time: ");
(void) y_time_time_print_div(ystop, NITERATIONS);
y_printf("\n");
(void) y_printf("\n");
isum = 0;
@ -154,17 +155,17 @@ main(void)
ystop = y_time_time_stop(ystart);
y_printf("\nWhen NOT using overflow:\n\n");
(void) y_printf("\nWhen NOT using overflow:\n\n");
y_printf("native sum: %d\nyc sum: %u\n", isum, ysum);
(void) y_printf("native sum: %d\nyc sum: %u\n", isum, ysum);
y_printf("native time: ");
(void) y_printf("native time: ");
(void) y_time_time_print_div(stop, NITERATIONS);
y_printf("\n");
(void) y_printf("\n");
y_printf("yc time: ");
(void) y_printf("yc time: ");
(void) y_time_time_print_div(ystop, NITERATIONS);
y_printf("\n");
(void) y_printf("\n");
y_exit(y_status_exits[y_STATUS_SUCCESS]);
}

@ -86,8 +86,8 @@ main(int argc, char* argv[])
nentries = st.size / sizeof(struct dirent);
y_printf("nentries: %zu, size: %llu, sizeof dirent: %zu\n", nentries,
st.size, sizeof(struct dirent));
(void) y_printf("nentries: %zu, size: %llu, sizeof dirent: %zu\n", nentries,
st.size, sizeof(struct dirent));
y_exit(y_status_exits[y_STATUS_SUCCESS]);
}

@ -147,7 +147,7 @@ bench(void)
y_time_time_double(stop2) / (double) (NITERATIONS * max * max));
}
y_putc('\n');
(void) y_putc('\n');
y_return_void_dbg;
}

@ -105,8 +105,8 @@ print_runs(const char* title, const y_Time arr[RUNS])
y_call_dbg();
y_printf("%s", title);
y_printf(":\n");
(void) y_printf("%s", title);
(void) y_printf(":\n");
for (l = 0; l < RUNS; ++l)
{
@ -114,7 +114,7 @@ print_runs(const char* title, const y_Time arr[RUNS])
(void) y_printf("\n");
}
y_printf("\n");
(void) y_printf("\n");
y_return_void_dbg;
}

@ -1073,7 +1073,8 @@ typedef y_u32 y_Dirent;
* @pre @a parent must have an entry associated with @a dirent.
*/
y_Path
y_fs_dirent_name(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
y_fs_dirent_name(const y_Dir parent,
y_Dirent dirent) y_allnonnull y_nodiscard y_inline;
/**
* Returns an index to the entry's extension.
@ -1084,7 +1085,8 @@ y_fs_dirent_name(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
* @pre @a parent must have an entry associated with @a dirent.
*/
y_u32
y_fs_dirent_ext(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
y_fs_dirent_ext(const y_Dir parent,
y_Dirent dirent) y_allnonnull y_nodiscard y_inline;
/**
* Returns the size of the entry (file size or directory data size in bytes).
@ -1095,7 +1097,8 @@ y_fs_dirent_ext(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
* @pre @a parent must have an entry associated with @a dirent.
*/
y_usize
y_fs_dirent_size(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
y_fs_dirent_size(const y_Dir parent,
y_Dirent dirent) y_allnonnull y_nodiscard y_inline;
/**
* Returns true if the entry is a directory.
@ -1106,7 +1109,8 @@ y_fs_dirent_size(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
* @pre @a parent must have an entry associated with @a dirent.
*/
bool
y_fs_dirent_isDir(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
y_fs_dirent_isDir(const y_Dir parent,
y_Dirent dirent) y_allnonnull y_nodiscard y_inline;
/**
* Returns true if the entry is a file.
@ -1117,7 +1121,8 @@ y_fs_dirent_isDir(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
* @pre @a parent must have an entry associated with @a dirent.
*/
bool
y_fs_dirent_isFile(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
y_fs_dirent_isFile(const y_Dir parent,
y_Dirent dirent) y_allnonnull y_nodiscard y_inline;
/**
* Returns the owner permissions for the entry.
@ -1129,7 +1134,7 @@ y_fs_dirent_isFile(const y_Dir parent, y_Dirent dirent) y_allnonnull y_inline;
*/
y_u8
y_fs_dirent_ownerPerms(const y_Dir parent,
y_Dirent dirent) y_allnonnull y_inline;
y_Dirent dirent) y_allnonnull y_nodiscard y_inline;
/**
* Returns the group permissions for the entry.
@ -1141,7 +1146,7 @@ y_fs_dirent_ownerPerms(const y_Dir parent,
*/
y_u8
y_fs_dirent_groupPerms(const y_Dir parent,
y_Dirent dirent) y_allnonnull y_inline;
y_Dirent dirent) y_allnonnull y_nodiscard y_inline;
/**
* Returns the other permissions for the entry.
@ -1153,7 +1158,7 @@ y_fs_dirent_groupPerms(const y_Dir parent,
*/
y_u8
y_fs_dirent_otherPerms(const y_Dir parent,
y_Dirent dirent) y_allnonnull y_inline;
y_Dirent dirent) y_allnonnull y_nodiscard y_inline;
/**
* @}
@ -1172,7 +1177,7 @@ y_fs_dirent_otherPerms(const y_Dir parent,
* @pre @a path must not be NULL.
*/
y_Status
y_fs_dir_mkdir(y_Path path) y_allnonnull;
y_fs_dir_mkdir(y_Path path) y_allnonnull y_nodiscard;
/**
* Creates the directory at @a path, which is treated as relative to @a parent.
@ -1182,7 +1187,7 @@ y_fs_dir_mkdir(y_Path path) y_allnonnull;
* @pre @a path must not be NULL.
*/
y_Status
y_fs_dir_mkdirat(y_Path path, y_Dir parent);
y_fs_dir_mkdirat(y_Path path, y_Dir parent) y_allnonnull y_nodiscard;
/**
* Creates the directory at @a path, making sure to create any missing parent
@ -1192,7 +1197,7 @@ y_fs_dir_mkdirat(y_Path path, y_Dir parent);
* @pre @a path must not be NULL.
*/
y_Status
y_fs_dir_mkdirp(y_Path path) y_allnonnull;
y_fs_dir_mkdirp(y_Path path) y_allnonnull y_nodiscard;
/**
* Opens and returns the directory at @a path. The opened directory must be
@ -1205,7 +1210,7 @@ y_fs_dir_mkdirp(y_Path path) y_allnonnull;
* @pre @a path must not be NULL.
*/
y_Status
y_fs_dir_open(y_Dir* d, y_Path path) y_allnonnull;
y_fs_dir_open(y_Dir* d, y_Path path) y_allnonnull y_nodiscard;
/**
* Reopens @a dir with @a path.
@ -1217,7 +1222,7 @@ y_fs_dir_open(y_Dir* d, y_Path path) y_allnonnull;
* @pre @a path must not be NULL.
*/
y_Status
y_fs_dir_reopen(y_Dir d, y_Path path) y_allnonnull;
y_fs_dir_reopen(y_Dir d, y_Path path) y_allnonnull y_nodiscard;
/**
* Opens a directory relative to a parent. This opens all intermediate parents,
@ -1233,7 +1238,7 @@ y_fs_dir_reopen(y_Dir d, y_Path path) y_allnonnull;
*/
y_Status
y_fs_dir_openat(y_Dir* d, y_Dir parent, y_Path path, bool mkdirs)
y_paramsnonnull(1);
y_paramsnonnull(1) y_nodiscard;
/**
* Returns true if the directory has another entry.
@ -1243,7 +1248,7 @@ y_fs_dir_openat(y_Dir* d, y_Dir parent, y_Path path, bool mkdirs)
* @pre @a d must be open.
*/
bool
y_fs_dir_hasNext(y_Dir d) y_allnonnull;
y_fs_dir_hasNext(y_Dir d) y_allnonnull y_nodiscard;
/**
* Loads the first entry in @a dir.
@ -1251,7 +1256,7 @@ y_fs_dir_hasNext(y_Dir d) y_allnonnull;
* @return y_STATUS_SUCCESS on success, an error code otherwise.
*/
y_Status
y_fs_dir_first(y_Dir dir) y_allnonnull y_inline;
y_fs_dir_first(y_Dir dir) y_allnonnull y_nodiscard y_inline;
/**
* Loads the next entry in @a dir.
@ -1260,7 +1265,7 @@ y_fs_dir_first(y_Dir dir) y_allnonnull y_inline;
* @pre @a dir must have been opened.
*/
y_Status
y_fs_dir_next(y_Dir dir) y_allnonnull;
y_fs_dir_next(y_Dir dir) y_allnonnull y_nodiscard;
/**
* Returns the y_Dirent of the current entry in the directory.
@ -1270,7 +1275,7 @@ y_fs_dir_next(y_Dir dir) y_allnonnull;
* @pre @a d must be open.
*/
y_Dirent
y_fs_dir_entry(y_Dir d) y_allnonnull;
y_fs_dir_entry(y_Dir d) y_allnonnull y_nodiscard;
/**
* Sorts the open directory @a d.
@ -1291,7 +1296,7 @@ y_fs_dir_sort(y_Dir d, bool dirsFirst) y_allnonnull;
* @pre @a d must have been opened.
*/
void
y_fs_dir_unsort(y_Dir d);
y_fs_dir_unsort(y_Dir d) y_allnonnull;
/**
* Opens the subdirectory of @a d at entry @a i. The directory must not be
@ -1304,7 +1309,7 @@ y_fs_dir_unsort(y_Dir d);
* @pre @a d must have an entry associated with @a i.
*/
y_Status
y_fs_dir_subdir(y_Dir d, y_Dirent i) y_allnonnull;
y_fs_dir_subdir(y_Dir d, y_Dirent i) y_allnonnull y_nodiscard;
/**
* Opens the parent of @a d into @a d. The directory must not be closed first.
@ -1314,7 +1319,7 @@ y_fs_dir_subdir(y_Dir d, y_Dirent i) y_allnonnull;
* @pre @a d must have been opened.
*/
y_Status
y_fs_dir_parent(y_Dir d) y_allnonnull;
y_fs_dir_parent(y_Dir d) y_allnonnull y_nodiscard;
/**
* Opens the home directory into @a d. The directory must not be closed first.
@ -1324,7 +1329,7 @@ y_fs_dir_parent(y_Dir d) y_allnonnull;
* @pre @a d must have been opened.
*/
y_Status
y_fs_dir_home(y_Dir d) y_allnonnull;
y_fs_dir_home(y_Dir d) y_allnonnull y_nodiscard;
/**
* Returns a pointer to the path of @a dir. The pointer will be invalidated if
@ -1335,7 +1340,7 @@ y_fs_dir_home(y_Dir d) y_allnonnull;
* @pre @a dir must have been opened.
*/
y_Path
y_fs_dir_path(y_Dir dir) y_allnonnull y_inline;
y_fs_dir_path(y_Dir dir) y_allnonnull y_nodiscard y_inline;
/**
* Returns the number of entries in @a dir.
@ -1345,7 +1350,7 @@ y_fs_dir_path(y_Dir dir) y_allnonnull y_inline;
* @pre @a dir must have been opened.
*/
y_u32
y_fs_dir_numEntries(y_Dir dir) y_allnonnull y_inline;
y_fs_dir_numEntries(y_Dir dir) y_allnonnull y_nodiscard y_inline;
/**
* Returns true if @a dir is sorted, false otherwise.
@ -1355,7 +1360,7 @@ y_fs_dir_numEntries(y_Dir dir) y_allnonnull y_inline;
* @pre @a dir must have been opened.
*/
bool
y_fs_dir_sorted(y_Dir dir) y_allnonnull y_inline;
y_fs_dir_sorted(y_Dir dir) y_allnonnull y_nodiscard y_inline;
/**
* Returns true if @a dir is sorted with directories first, false otherwise.
@ -1365,7 +1370,7 @@ y_fs_dir_sorted(y_Dir dir) y_allnonnull y_inline;
* @pre @a dir must have been opened.
*/
bool
y_fs_dir_dirsFirst(y_Dir dir) y_allnonnull y_inline;
y_fs_dir_dirsFirst(y_Dir dir) y_allnonnull y_nodiscard y_inline;
/**
* Closes the directory @a dir.
@ -1478,7 +1483,7 @@ y_fs_filebytes_destroy(void* filebytes) y_allnonnull y_inline;
* @return y_STATUS_SUCCESS on success, an error code otherwise.
*/
y_Status
y_fs_file_create(y_Path path) y_allnonnull y_inline;
y_fs_file_create(y_Path path) y_allnonnull y_nodiscard y_inline;
/**
* Creates the file at @a path, making sure to create any missing parent
@ -1487,7 +1492,7 @@ y_fs_file_create(y_Path path) y_allnonnull y_inline;
* @return y_STATUS_SUCCESS on success, an error code otherwise.
*/
y_Status
y_fs_file_createWithParents(y_Path path) y_allnonnull;
y_fs_file_createWithParents(y_Path path) y_allnonnull y_nodiscard;
/**
* Creates a temp file name, creates the file, and returns the path to the file.
@ -1500,7 +1505,8 @@ y_fs_file_createWithParents(y_Path path) y_allnonnull;
* @pre @a prefix must be valid.
*/
y_Status
y_fs_file_temp(y_Path* path, y_Path dir, y_Path prefix) y_allnonnull;
y_fs_file_temp(y_Path* path, y_Path dir,
y_Path prefix) y_allnonnull y_nodiscard;
/**
* A cross-platform fopen.
@ -1512,7 +1518,7 @@ y_fs_file_temp(y_Path* path, y_Path dir, y_Path prefix) y_allnonnull;
* @pre @a path.a must not be NULL.
*/
y_Status
y_fs_file_open(y_File* f, y_Path path, y_u8 mode) y_allnonnull;
y_fs_file_open(y_File* f, y_Path path, y_u8 mode) y_allnonnull y_nodiscard;
/**
* A cross-platform fopen that safely opens all directories above, starting at
@ -1533,7 +1539,7 @@ y_fs_file_open(y_File* f, y_Path path, y_u8 mode) y_allnonnull;
*/
y_Status
y_fs_file_openAt(y_File* f, y_Dir parent, y_Path path, y_u8 mode)
y_paramsnonnull(1);
y_paramsnonnull(1) y_nodiscard;
/**
* Gets the realpath of @a path and open it, checking that the file at the
@ -1552,7 +1558,7 @@ y_fs_file_openAt(y_File* f, y_Dir parent, y_Path path, y_u8 mode)
*/
y_Status
y_fs_file_openRealpath(y_File* f, y_Path* realpath, y_Path path,
y_u8 mode) y_allnonnull;
y_u8 mode) y_allnonnull y_nodiscard;
/**
* Gets the realpath of @a path and open it, checking that the file at the
@ -1573,7 +1579,7 @@ y_fs_file_openRealpath(y_File* f, y_Path* realpath, y_Path path,
*/
y_Status
y_fs_file_openAtRealpath(y_File* f, y_Path* realpath, y_Dir parent, y_Path path,
y_u8 mode) y_allnonnull;
y_u8 mode) y_allnonnull y_nodiscard;
/**
* Gets information about an open file.
@ -1585,7 +1591,7 @@ y_fs_file_openAtRealpath(y_File* f, y_Path* realpath, y_Dir parent, y_Path path,
* @pre @a st must not be NULL.
*/
y_Status
y_fs_file_stat(y_File f, y_Stat* st) y_allnonnull;
y_fs_file_stat(y_File f, y_Stat* st) y_allnonnull y_nodiscard;
/**
* The type of seeks available on files.
@ -1613,7 +1619,8 @@ typedef enum
* @pre @a f must have been opened.
*/
y_Status
y_fs_file_seek(y_File f, y_FileSeek seek, y_offset off) y_allnonnull;
y_fs_file_seek(y_File f, y_FileSeek seek,
y_offset off) y_allnonnull y_nodiscard;
/**
* Sets the length of a file. If the file size cannot be set, such as if the
@ -1626,7 +1633,7 @@ y_fs_file_seek(y_File f, y_FileSeek seek, y_offset off) y_allnonnull;
* @pre @a f must not be NULL.
*/
y_Status
y_fs_file_truncate(y_File f, y_offset len) y_allnonnull;
y_fs_file_truncate(y_File f, y_offset len) y_allnonnull y_nodiscard;
/**
* Returns the size of a file.
@ -1638,7 +1645,7 @@ y_fs_file_truncate(y_File f, y_offset len) y_allnonnull;
* @pre @a size must not be NULL.
*/
y_Status
y_fs_file_size(y_File f, y_ullong* size) y_allnonnull;
y_fs_file_size(y_File f, y_ullong* size) y_allnonnull y_nodiscard;
/**
* Syncs a file to disk. This ensures that the file persists. If the file is not
@ -1654,7 +1661,7 @@ y_fs_file_size(y_File f, y_ullong* size) y_allnonnull;
* @pre @a f must have been opened.
*/
y_Status
y_fs_file_sync(y_File f, y_uint ndirs) y_allnonnull y_inline;
y_fs_file_sync(y_File f, y_uint ndirs) y_allnonnull y_nodiscard y_inline;
/**
* Copies a file to a new path. The new file is a copy, not a link. If the
@ -1664,7 +1671,7 @@ y_fs_file_sync(y_File f, y_uint ndirs) y_allnonnull y_inline;
* @return An error code, if any.
*/
y_Status
y_fs_file_copy(y_Path dest, y_Path src);
y_fs_file_copy(y_Path dest, y_Path src) y_nodiscard;
/**
* Closes a file and destroys it. Because this cannot return any error code in
@ -1682,7 +1689,7 @@ y_fs_file_close(void* file) y_allnonnull y_inline;
* @return An error code, if any.
*/
y_Status
y_putc(y_uchar c);
y_putc(y_uchar c) y_nodiscard;
/**
* Prints a character to stderr.
@ -1690,7 +1697,7 @@ y_putc(y_uchar c);
* @return An error code, if any.
*/
y_Status
y_eputc(y_uchar c);
y_eputc(y_uchar c) y_nodiscard;
/**
* Prints a character to a file.
@ -1701,7 +1708,7 @@ y_eputc(y_uchar c);
* @pre @a f must have been opened.
*/
y_Status
y_fputc(y_File f, y_uchar c) y_allnonnull;
y_fputc(y_File f, y_uchar c) y_allnonnull y_nodiscard;
/**
* Gets a character from stdin.
@ -1710,7 +1717,7 @@ y_fputc(y_File f, y_uchar c) y_allnonnull;
* @pre @a c must not be NULL.
*/
y_Status
y_getc(y_uchar* c) y_allnonnull;
y_getc(y_uchar* c) y_allnonnull y_nodiscard;
/**
* Gets a character from a file.
@ -1720,7 +1727,7 @@ y_getc(y_uchar* c) y_allnonnull;
* @pre @a c must not be NULL.
*/
y_Status
y_fgetc(y_File f, y_uchar* c) y_allnonnull;
y_fgetc(y_File f, y_uchar* c) y_allnonnull y_nodiscard;
/**
* Prints a string to stdout.
@ -1729,7 +1736,7 @@ y_fgetc(y_File f, y_uchar* c) y_allnonnull;
* @pre @a str must not be NULL.
*/
y_Status
y_puts(const char* str) y_allnonnull y_inline;
y_puts(const char* str) y_allnonnull y_nodiscard y_inline;
/**
* Prints a string to stderr.
@ -1738,7 +1745,7 @@ y_puts(const char* str) y_allnonnull y_inline;
* @pre @a str must not be NULL.
*/
y_Status
y_eputs(const char* str) y_allnonnull y_inline;
y_eputs(const char* str) y_allnonnull y_nodiscard y_inline;
/**
* Prints a string to a file.
@ -1750,7 +1757,7 @@ y_eputs(const char* str) y_allnonnull y_inline;
* @pre @a str must not be NULL.
*/
y_Status
y_fputs(y_File f, const char* str) y_allnonnull;
y_fputs(y_File f, const char* str) y_allnonnull y_nodiscard;
/**
* Gets a line from stdin. A max of @a n - 1 characters are read. This is
@ -1764,7 +1771,7 @@ y_fputs(y_File f, const char* str) y_allnonnull;
* @pre @a buf must be at least @a n bytes.
*/
y_Status
y_gets(y_uchar* buf, y_usize n, y_usize* nread) y_paramsnonnull(1);
y_gets(y_uchar* buf, y_usize n, y_usize* nread) y_paramsnonnull(1) y_nodiscard;
/**
* Gets a line from a file. A max of @a n - 1 characters are read. This is
@ -1782,7 +1789,7 @@ y_gets(y_uchar* buf, y_usize n, y_usize* nread) y_paramsnonnull(1);
*/
y_Status
y_fgets(y_File f, y_uchar* buf, y_usize n, y_usize* nread)
y_paramsnonnull(1, 2);
y_paramsnonnull(1, 2) y_nodiscard;
// TODO: Make it so the printf functions can return the number of characters
// printed, probably with a pointer argument.
@ -1795,7 +1802,8 @@ y_fgets(y_File f, y_uchar* buf, y_usize n, y_usize* nread)
* @pre @a fmt must not be NULL.
*/
y_Status
y_printf(const char* const fmt, ...) y_allnonnull y_inline y_formatprintf(1, 2);
y_printf(const char* const fmt, ...) y_allnonnull y_nodiscard y_inline
y_formatprintf(1, 2);
/**
* Prints formatted output to stderr. The formatting is exactly according to the
@ -1805,7 +1813,7 @@ y_printf(const char* const fmt, ...) y_allnonnull y_inline y_formatprintf(1, 2);
* @pre @a fmt must not be NULL.
*/
y_Status
y_eprintf(const char* const fmt, ...) y_allnonnull y_inline
y_eprintf(const char* const fmt, ...) y_allnonnull y_nodiscard y_inline
y_formatprintf(1, 2);
/**
@ -1819,7 +1827,7 @@ y_eprintf(const char* const fmt, ...) y_allnonnull y_inline
* @pre @a fmt must not be NULL.
*/
y_Status
y_fprintf(y_File f, const char* const fmt, ...) y_allnonnull
y_fprintf(y_File f, const char* const fmt, ...) y_allnonnull y_nodiscard
y_formatprintf(2, 3);
/**
@ -1833,7 +1841,8 @@ y_fprintf(y_File f, const char* const fmt, ...) y_allnonnull
* @pre @a args must be valid.
*/
y_Status
y_vprintf(const char* const fmt, va_list args) y_allnonnull y_inline;
y_vprintf(const char* const fmt,
va_list args) y_allnonnull y_nodiscard y_inline;
/**
* Prints formatted output to stderr using a va_list. The formatting is exactly
@ -1846,7 +1855,8 @@ y_vprintf(const char* const fmt, va_list args) y_allnonnull y_inline;
* @pre @a args must be valid.
*/
y_Status
y_veprintf(const char* const fmt, va_list args) y_allnonnull y_inline;
y_veprintf(const char* const fmt,
va_list args) y_allnonnull y_nodiscard y_inline;
/**
* Prints formatted output to a file using a va_list. The formatting is exactly
@ -1862,7 +1872,8 @@ y_veprintf(const char* const fmt, va_list args) y_allnonnull y_inline;
* @pre @a args must be valid.
*/
y_Status
y_vfprintf(y_File f, const char* const fmt, va_list args) y_allnonnull;
y_vfprintf(y_File f, const char* const fmt,
va_list args) y_allnonnull y_nodiscard;
/**
* Reads at most @a n characters from stdin into @a buf. The number of
@ -1875,7 +1886,8 @@ y_vfprintf(y_File f, const char* const fmt, va_list args) y_allnonnull;
* @pre @a buf must have at least @a n bytes of space.
*/
y_Status
y_read(y_uchar* buf, y_usize n, y_usize* nread) y_paramsnonnull(1) y_inline;
y_read(y_uchar* buf, y_usize n, y_usize* nread)
y_paramsnonnull(1) y_nodiscard y_inline;
/**
* Reads at most @a n characters from a file into @a buf. The number of
@ -1891,7 +1903,7 @@ y_read(y_uchar* buf, y_usize n, y_usize* nread) y_paramsnonnull(1) y_inline;
* @pre @a buf must have at least @a n bytes of space.
*/
y_Status
y_fread(y_File f, y_uchar* buf, y_usize n, y_usize* nread) y_inline
y_fread(y_File f, y_uchar* buf, y_usize n, y_usize* nread) y_nodiscard y_inline
y_paramsnonnull(1, 2);
/**
@ -1906,7 +1918,7 @@ y_fread(y_File f, y_uchar* buf, y_usize n, y_usize* nread) y_inline
*/
y_Status
y_write(const char* buf, y_usize n, y_usize* nwritten)
y_paramsnonnull(1) y_inline;
y_paramsnonnull(1) y_nodiscard y_inline;
/**
* Writes at most @a n characters from @a buf to a file. The number of
@ -1923,21 +1935,21 @@ y_write(const char* buf, y_usize n, y_usize* nwritten)
*/
y_Status
y_fwrite(y_File f, const char* buf, y_usize n, y_usize* nwritten)
y_paramsnonnull(1, 2);
y_paramsnonnull(1, 2) y_nodiscard;
/**
* Flushes stdout.
* @return An error code, if any.
*/
y_Status
y_flush(void) y_inline;
y_flush(void) y_nodiscard y_inline;
/**
* Flushes stderr.
* @return An error code, if any.
*/
y_Status
y_eflush(void) y_inline;
y_eflush(void) y_nodiscard y_inline;
/**
* Flushes a file.
@ -1947,7 +1959,7 @@ y_eflush(void) y_inline;
* @pre @a f must have been opened.
*/
y_Status
y_fflush(y_File f) y_allnonnull;
y_fflush(y_File f) y_allnonnull y_nodiscard;
/**
* Reads the entirety of the file at @a path and returns a @a y_FileBytes (byte
@ -1962,7 +1974,8 @@ y_fflush(y_File f) y_allnonnull;
* @pre @a bytes must not be NULL.
*/
y_Status
y_fs_filebytes_read(y_FileBytes* bytes, y_Path path, bool binary) y_allnonnull;
y_fs_filebytes_read(y_FileBytes* bytes, y_Path path,
bool binary) y_allnonnull y_nodiscard;
/**
* Reads the entirety of the file @a file and returns a @a y_FileBytes (byte
@ -1982,7 +1995,7 @@ y_fs_filebytes_read(y_FileBytes* bytes, y_Path path, bool binary) y_allnonnull;
*/
y_Status
y_fs_filebytes_fread(y_FileBytes* bytes, y_File file, y_ullong size,
bool binary) y_allnonnull;
bool binary) y_allnonnull y_nodiscard;
/**
* Reads the entirety of the file at @a path and returns a @a y_FileBytes (byte
@ -1999,7 +2012,8 @@ y_fs_filebytes_fread(y_FileBytes* bytes, y_File file, y_ullong size,
* @pre @a path must be valid.
*/
y_Status
y_fs_filebytes_sread(y_FileBytes* bytes, y_Path path, bool binary) y_allnonnull;
y_fs_filebytes_sread(y_FileBytes* bytes, y_Path path,
bool binary) y_allnonnull y_nodiscard;
/**
* @}

@ -111,38 +111,39 @@ main(int argc, char* argv[])
// Make sure we have a file name.
if (argc != 2)
{
y_eprintf("Usage: test filename\n");
(void) y_eprintf("Usage: test filename\n");
return 1;
}
// Copy the path.
s = y_fs_path_init_cstr(&path, argv[1]);
if (y_err(s != y_STATUS_SUCCESS)) return (int) s;
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
// Stat the file.
e = y_fs_path_stat(path, &st, false, true);
if (e != y_ERROR_SUCCESS)
{
y_eprintf("Error opening file");
(void) y_eprintf("Error opening file");
goto err;
}
s = y_str_pchar2str(&path_str, path.a);
if (e != y_ERROR_SUCCESS)
{
y_eprintf("Error converting path");
(void) y_eprintf("Error converting path");
goto err;
}
// Print out the info.
y_printf("Path: %s\n Name: %s\n Is dir? %s\n Is file? %s\n"
" Read? %s\n Write? %s\n Execute? %s\n",
y_str_str(&path_str), basename(argv[1]),
st.type == y_STAT_TYPE_DIR ? yes : no,
st.type == y_STAT_TYPE_REGULAR ? yes : no,
st.uperms & y_STAT_PERM_READ ? yes : no,
st.uperms & y_STAT_PERM_WRITE ? yes : no,
st.uperms & y_STAT_PERM_EXEC ? yes : no);
s = y_printf("Path: %s\n Name: %s\n Is dir? %s\n Is file? %s\n"
" Read? %s\n Write? %s\n Execute? %s\n",
y_str_str(&path_str), basename(argv[1]),
st.type == y_STAT_TYPE_DIR ? yes : no,
st.type == y_STAT_TYPE_REGULAR ? yes : no,
st.uperms & y_STAT_PERM_READ ? yes : no,
st.uperms & y_STAT_PERM_WRITE ? yes : no,
st.uperms & y_STAT_PERM_EXEC ? yes : no);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
y_str_destroy(&path_str);

@ -117,7 +117,7 @@ main(void)
// Check the status.
if (y_err(s != y_STATUS_SUCCESS))
{
y_eprintf("Error opening file");
(void) y_eprintf("Error opening file");
goto bail;
}
@ -135,8 +135,9 @@ main(void)
s = y_str_pchar2str(&path_str, y_fs_dir_path(dir).a);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
y_printf("==========\nDIRECTORY: %s\n==========\n\n",
y_str_str(&path_str));
s = y_printf("==========\nDIRECTORY: %s\n==========\n\n",
y_str_str(&path_str));
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
y_str_destroy(&path_str);
@ -144,25 +145,36 @@ main(void)
for (i = 0; i < y_fs_dir_numEntries(dir); i++)
{
// If it is a directory, print the index.
if (y_fs_dirent_isDir(dir, i)) y_printf("[%u] ", i);
if (y_fs_dirent_isDir(dir, i))
{
s = y_printf("[%u] ", i);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
s = y_str_pchar2str(&path_str, y_fs_dirent_name(dir, i).a);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
// Print the name.
y_printf("%s", y_str_str(&path_str));
s = y_printf("%s", y_str_str(&path_str));
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
y_str_destroy(&path_str);
// Print slashes for directories.
if (y_fs_dirent_isDir(dir, i)) y_putc(y_FS_PATH_SEP);
if (y_fs_dirent_isDir(dir, i))
{
s = y_putc(y_FS_PATH_SEP);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
// Add a newline.
y_putc('\n');
s = y_putc('\n');
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
// Ask the user for input.
y_printf("? ");
s = y_printf("? ");
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
// Get the input and if it isn't valid, break.
if (y_gets(input, 256, NULL) != y_STATUS_SUCCESS) break;
@ -176,12 +188,13 @@ main(void)
// Go to the subdirectory.
if (y_fs_dir_subdir(dir, (y_uint) choice))
{
y_eprintf("Error opening subdirectory");
(void) y_eprintf("Error opening subdirectory");
goto bail;
}
// Put an extra newline to separate.
y_putc('\n');
s = y_putc('\n');
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
}

@ -112,7 +112,7 @@ main(void)
s = y_fs_dir_open(&dir, path);
if (y_err(s != y_STATUS_SUCCESS))
{
y_eprintf("Error opening file");
(void) y_eprintf("Error opening file");
goto bail;
}
@ -124,15 +124,21 @@ main(void)
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
// Get the name and print it.
y_printf("%s", y_str_str(&path_str));
s = y_printf("%s", y_str_str(&path_str));
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
y_str_destroy(&path_str);
// If it is a directory, print a slash.
if (y_fs_dirent_isDir(dir, i)) y_putc(y_FS_PATH_SEP);
if (y_fs_dirent_isDir(dir, i))
{
s = y_putc(y_FS_PATH_SEP);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
// Add a newline.
y_putc('\n');
s = y_putc('\n');
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
// Close the directory.

@ -151,17 +151,20 @@ main(void)
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
// Write the name to the file with a slash for directories
y_fputs(fp, y_str_str(&name_str));
s = y_fputs(fp, y_str_str(&name_str));
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
y_str_destroy(&name_str);
if (y_fs_dirent_isDir(dir, i))
{
y_fputs(fp, y_FS_PATH_SEP_STR);
s = y_fputs(fp, y_FS_PATH_SEP_STR);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
// Add a newline.
y_fputc(fp, '\n');
s = y_fputc(fp, '\n');
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
// Free the data.

@ -114,7 +114,7 @@ main(int argc, char* argv[])
s = y_fs_dir_open(&dir, path);
if (y_err(s != y_STATUS_SUCCESS))
{
y_eprintf("Error opening file");
(void) y_eprintf("Error opening file");
goto bail;
}
@ -127,15 +127,21 @@ main(int argc, char* argv[])
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
// Get the name and print it.
y_printf("%s", y_str_str(&path_str));
s = y_printf("%s", y_str_str(&path_str));
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
y_str_destroy(&path_str);
// Print a slash for directories.
if (y_fs_dirent_isDir(dir, i)) y_putc(y_FS_PATH_SEP);
if (y_fs_dirent_isDir(dir, i))
{
s = y_putc(y_FS_PATH_SEP);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
// Add a newline.
y_putc('\n');
s = y_putc('\n');
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
// Close the directory.

@ -142,7 +142,8 @@ rig_targetExists(rig_rig* r, rig_Target** t, rig_TargetID id)
type = id.symbol ? "Non-file" : "File";
y_eprintf("%s target does not exist: %s\n", type, y_str_str(&id.name));
(void) y_eprintf("%s target does not exist: %s\n", type,
y_str_str(&id.name));
y_return_dbg(false);
}
@ -346,8 +347,8 @@ rig_queueLeafTarget(rig_rig* r, y_Path create_dir, rig_TargetID id,
// If the file does not exist, error and return.
if (y_err(!y_fs_path_exists(source_file, true)))
{
y_eprintf("File or directory does not exist: %s\n",
y_str_str(&id.name));
(void) y_eprintf("File or directory does not exist: %s\n",
y_str_str(&id.name));
// I just write the status here because I want all non-existent files
// reported.
@ -421,7 +422,7 @@ rig_invalidTarget(bool symbol, const char* name)
s = symbol ? y_STATUS_RIG_INVALID_TARGET : y_STATUS_RIG_INVALID_FILE_TARGET;
y_eprintf("%s: %s\n", y_error_msgs[s], name);
(void) y_eprintf("%s: %s\n", y_error_msgs[s], name);
y_strucon_setStatus(s);
y_return_dbg(s);
@ -533,7 +534,7 @@ rig_queue(rig_rig* r, rig_TargetIDArray tgts)
if (y_err(y_svec_len(&r->targets) == 0))
{
y_eprintf("No targets exist\n");
(void) y_eprintf("No targets exist\n");
s = y_STATUS_RIG_INVALID_DEFAULT_TARGET;
y_strucon_setStatus(s);
goto err;
@ -566,7 +567,7 @@ rig_queue(rig_rig* r, rig_TargetIDArray tgts)
s = rig_queueTarget(r, t, y_list_tail_id(&r->queue));
if (y_err(s != y_STATUS_SUCCESS))
{
y_eprintf("Could not queue target; quitting...\n");
(void) y_eprintf("Could not queue target; quitting...\n");
goto err;
}
}
@ -783,7 +784,8 @@ rig_runCmd(y_Proc_PipelineResult* res, y_proc_cmd* c, void* data, bool capture)
{
if (cmdres->retcode >= y_EXIT_EXEC_INVALID_PATH)
{
y_eprintf("Failed to execute command\n");
(void) y_eprintf("Failed to execute command\n");
s = y_strucon_handleError(y_ERROR_CHILD_CREATE_ERR);
break;
}
else
@ -969,8 +971,9 @@ rig_thread(void* ptr1, void* ptr2)
y_Path source_file;
// TODO: Clear the line, like ninja does, when on a tty.
y_printf("[%zu/%zu] Copying %s\n", started, total,
y_str_str(&t->id.name));
s = y_printf("[%zu/%zu] Copying %s\n", started, total,
y_str_str(&t->id.name));
if (y_err(s != y_STATUS_SUCCESS)) break;
s = y_stackpool_enterScope(pool);
if (y_err(s != y_STATUS_SUCCESS)) break;
@ -1020,16 +1023,18 @@ rig_thread(void* ptr1, void* ptr2)
if (t->id.symbol)
{
// TODO: Clear the line, like ninja does, when on a tty.
y_printf("[%zu/%zu] Executing target %s\n", started, total,
y_str_str(&t->id.name));
s = y_printf("[%zu/%zu] Executing target %s\n", started, total,
y_str_str(&t->id.name));
}
else
{
// TODO: Clear the line, like ninja does, when on a tty.
y_printf("[%zu/%zu] Building file target %s\n", started, total,
y_str_str(&t->id.name));
s = y_printf("[%zu/%zu] Building file target %s\n", started,
total, y_str_str(&t->id.name));
}
if (y_err(s != y_STATUS_SUCCESS)) break;
s = rig_target_init_exec(t);
if (y_err(s != y_STATUS_SUCCESS)) break;
@ -1201,13 +1206,14 @@ rig_execBuild(rig_rig* r)
{
if (i >= 1)
{
y_eprintf("Could not start %zu requested threads; "
"continuing with %zu threads...\n",
r->ncores, i);
(void) y_eprintf("Could not start %zu requested threads; "
"continuing with %zu threads...\n",
r->ncores, i);
}
else
{
y_eprintf("Could not start any threads; quitting...\n");
(void) y_eprintf("Could not start any threads; "
"quitting...\n");
r->status = y_STATUS_THREAD_CREATE_ERR;
y_strucon_setStatus(r->status);
}

@ -122,7 +122,7 @@ rig_db_paths_lock(rig_db_paths* p)
if (y_err(s == y_STATUS_FILE_EXISTS))
{
y_eprintf("Could not lock build database\n");
(void) y_eprintf("Could not lock build database\n");
s = y_STATUS_LOCK_FILE_EXISTS;
}

@ -347,7 +347,7 @@ rigc_main(int argc, y_pchar* argv[])
if (argc < 2)
{
y_eprintf("Must provide the source directory\n");
(void) y_eprintf("Must provide the source directory\n");
y_return_p(y_STATUS_MISSING_CMD_LINE_ARG, pool);
}
@ -365,8 +365,10 @@ rigc_main(int argc, y_pchar* argv[])
if (!y_fs_path_isFile(gaml_path, true))
{
y_eprintf("No build.gaml file in given source directory\n");
(void) y_eprintf("No build.gaml file in given source directory\n");
s = y_strucon_handleError(y_ERROR_DOES_NOT_EXIST);
y_return_p(s, pool);
}
@ -500,9 +502,11 @@ rig_main(int argc, y_pchar* argv[])
default:
{
y_eprintf("%s\n", y_opt_errmsg(opt));
y_return_p(y_strucon_handleError(y_ERROR_INVALID_CMD_LINE_ARG),
pool);
(void) y_eprintf("%s\n", y_opt_errmsg(opt));
s = y_strucon_handleError(y_ERROR_INVALID_CMD_LINE_ARG);
y_return_p(s, pool);
}
}
}

@ -246,8 +246,8 @@ rig_handleGamlTypeErr(const char* file, const char* key, y_GamlType type)
name = y_gaml_type_names[type];
y_eprintf("Key \"%s\" in file \"%s\" must have a value of type %s\n", file,
key, name);
(void) y_eprintf("Key \"%s\" in file \"%s\" must have a value of type %s\n",
file, key, name);
s = y_strucon_handleError(y_ERROR_GAML_TYPE_ERR);

@ -698,7 +698,7 @@ y_sys_os_init(bool need_children, bool need_timers, bool need_signals)
if (y_err(s != y_STATUS_SUCCESS))
{
// Just bail out of the program. Nothing we can do about it.
y_eprintf("Could not set up a signal pipe");
(void) y_eprintf("Could not set up a signal pipe");
exit((int) s);
}

@ -1497,7 +1497,8 @@ yao_parse_validKeywordType(yao_ExprItem* cur, y_uchar last)
}
if (y_err((((y_uchar) cur->t) == ((y_uchar) yao_OP_TYPE_LEFT_ASSOCIATIVE) ||
((y_uchar) cur->t) == ((y_uchar) yao_OP_TYPE_RIGHT_ASSOCIATIVE)) &&
((y_uchar) cur->t) ==
((y_uchar) yao_OP_TYPE_RIGHT_ASSOCIATIVE)) &&
(last == yao_OP_TYPE_LEFT_ASSOCIATIVE ||
last == yao_OP_TYPE_RIGHT_ASSOCIATIVE ||
last == yao_OP_TYPE_POSTFIX)))

@ -372,7 +372,7 @@ y_errexit(y_Status s)
{
if (y_err(s != y_STATUS_SUCCESS))
{
y_eprintf("%s\n", y_errmsg(s));
(void) y_eprintf("%s\n", y_errmsg(s));
}
exit((int) y_status_exits[s]);
@ -1742,7 +1742,7 @@ y_errorHandler(void* ptr, y_Error e, y_Status* ret)
y_call_dbg();
y_eprintf("%s\n", y_error_msgs[e]);
(void) y_eprintf("%s\n", y_error_msgs[e]);
*ret = (y_Status) e;

@ -387,7 +387,7 @@ yvm_exec_registerTarget(yvm_Exec* e, void* data, yvm_InstValArray args)
err = y_ERROR_RIG_FILE_TARGET_EXISTS;
}
y_eprintf("%s: %s\n", y_error_msgs[err], y_str_str(valstr));
(void) y_eprintf("%s: %s\n", y_error_msgs[err], y_str_str(valstr));
y_strucon_setStatus((y_Status) err);

@ -78,7 +78,7 @@ finalize(y_uint errors)
if (errors != 0)
{
y_fprintf(y_stderr, "Number of errors: %d\n", errors);
(void) y_fprintf(y_stderr, "Number of errors: %d\n", errors);
}
#if YC_ENABLE_ALLOC_ACCOUNTING && YC_ENABLE_STACKTRACES

@ -85,7 +85,8 @@ main(void)
idx = array_all_str.len - 1;
c = (char) y_str_i(array_all_str, idx);
y_printf("%c\n", c);
s = y_printf("%c\n", c);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
finalize(0);
}

@ -107,7 +107,7 @@ check_map(y_Map m, y_Vector vec)
if (ptr == NULL || (*ptr) != i)
{
y_eprintf("Failed to get the just inserted element\n");
(void) y_eprintf("Failed to get the just inserted element\n");
abort();
}
}

@ -193,7 +193,11 @@ main(void)
// Go to the next file.
has_next = y_fs_dir_hasNext(dir);
if (has_next) y_fs_dir_next(dir);
if (has_next)
{
s = y_fs_dir_next(dir);
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]);
}
}
// Register an error if we didn't find it.

@ -103,7 +103,8 @@ main(int argc, char* argv[])
if (argc < 4)
{
y_printf("usage: %s input output name [remove_tabs]]\n", argv[0]);
(void) y_eprintf("usage: %s input output name [remove_tabs]]\n",
argv[0]);
y_exit(y_status_exits[y_STATUS_INVALID_ARG]);
}