Closed ghuls closed 7 years ago
Does adf32f3 fix all warnings?
It fixes the getwd related warnings.
This is the only warning I get now for zip.cpp:
zopfli/blocksplitter.c optipng/opngreduc/opngreduc.c LzFind.c miniz/miniz.c
g++ -pthread -Ofast -std=gnu++11 -fsigned-char main.cpp blocksplitter.o codec.o image.o lz77.o opngreduc.o squeeze.o util.o LzFind.o miniz.o support.cpp zopflipng.cpp zopfli/deflate.cpp zopfli/zopfli_gzip.cpp zopfli/katajainen.cpp lodepng/lodepng.cpp lodepng/lodepng_util.cpp optipng/optipng.cpp jpegtran.cpp gztools.cpp leanify/zip.cpp leanify/leanify.cpp mozjpeg/.libs/libjpeg.a libpng/libpng.a zlib/libz.a -o ../ect
leanify/zip.cpp: In member function ‘uint32_t Zip::RecompressFile(unsigned char*, uint32_t, uint32_t, std::__cxx11::string, const ECTOptions&)’:
leanify/zip.cpp:214:54: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
fread(data - size_leanified, 1, new_size, stream);
^
Probably a check should be added to make sure that t0 is not NULL and tha tmp becomes no longer than MAXPATHLEN:
char* t0 = getcwd(0, MAXPATHLEN - 7 - extension..length());
From getcwd manual:
The getcwd() function copies an absolute pathname of the current working directory to the
array pointed to by buf, which is of length size.
If the length of the absolute pathname of the current working directory, including the
terminating null byte, exceeds size bytes, NULL is returned, and errno is set to ERANGE;
an application should check for this error, and allocate a larger buffer if necessary.
As an extension to the POSIX.1-2001 standard, glibc's getcwd() allocates the buffer dynam‐
ically using malloc(3) if buf is NULL. In this case, the allocated buffer has the length
size unless size is zero, when buf is allocated as big as necessary. The caller should
free(3) the returned buffer.
9d8ff57 should fix the last warning. Feel free to reopen this if you still have problems.
Use getcwd instead of getwd: