From fcfd2ada750c5d14cb2a99977d80b3a05683a3e0 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 16 Jun 2023 11:20:15 -0400 Subject: [PATCH] Fix build warnings/errs w/ -DNO_GETENV/-DNO_PUTENV - strtest.c: Fix unused variable warnings if both -DNO_GETENV and -DNO_PUTENV are specified or if only -DNO_GETENV is specified. - jinclude.h: Fix build error if only -DNO_GETENV is specified. Fixes #697 --- jinclude.h | 4 +++- strtest.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jinclude.h b/jinclude.h index e8d983ac..56e7a4b2 100644 --- a/jinclude.h +++ b/jinclude.h @@ -4,7 +4,7 @@ * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1994, Thomas G. Lane. * libjpeg-turbo Modifications: - * Copyright (C) 2022, D. R. Commander. + * Copyright (C) 2022-2023, D. R. Commander. * For conditions of distribution and use, see the accompanying README.ijg * file. * @@ -123,6 +123,8 @@ static INLINE int GETENV_S(char *buffer, size_t buffer_size, const char *name) #else +#include + /* This provides a similar interface to the Microsoft _putenv_s() function, but * other than parameter validation, it has no advantages over setenv(). */ diff --git a/strtest.c b/strtest.c index 88b568c9..3d5e004c 100644 --- a/strtest.c +++ b/strtest.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2022 D. R. Commander. All Rights Reserved. + * Copyright (C)2022-2023 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -55,8 +55,12 @@ void invalid_parameter_handler(const wchar_t *expression, int main(int argc, char **argv) { +#if !defined(NO_GETENV) || !defined(NO_PUTENV) int err; +#endif +#ifndef NO_GETENV char env[3]; +#endif #ifdef _MSC_VER _set_invalid_parameter_handler(invalid_parameter_handler);