X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=src%2Fcompat%2Fmemstream.h;h=374a5e729a2a644058b6f8d6292ad534084023cb;hb=84268ffbf1f963892215dc91ccec78367ee31f5e;hp=8dea7a44f13f5d5f79ae75c610eee4b04a15ebd2;hpb=578e048b5debf169e286e5b5cc747b5d6c16886d;p=babeltrace.git diff --git a/src/compat/memstream.h b/src/compat/memstream.h index 8dea7a44..374a5e72 100644 --- a/src/compat/memstream.h +++ b/src/compat/memstream.h @@ -1,30 +1,14 @@ -#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H -#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H - /* - * Copyright 2012 (c) - Mathieu Desnoyers - * - * memstream compatibility layer. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * Copyright 2012 (c) Mathieu Desnoyers * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * memstream compatibility layer. */ +#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H +#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H + #ifdef BABELTRACE_HAVE_FMEMOPEN #include @@ -69,7 +53,7 @@ FILE *bt_fmemopen(void *buf, size_t size, const char *mode) /* Build a temporary filename */ tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL); - if (_mktemp(tmpname) == NULL) { + if (!_mktemp(tmpname)) { goto error_free; } @@ -190,7 +174,10 @@ FILE *bt_open_memstream(char **ptr, size_t *sizeloc) } static inline -int bt_close_memstream(char **buf, size_t *size, FILE *fp) +int bt_close_memstream( + char **buf __attribute__((unused)), + size_t *size __attribute__((unused)), + FILE *fp) { return fclose(fp); } @@ -210,14 +197,15 @@ int bt_close_memstream(char **buf, size_t *size, FILE *fp) * into the buffer (which we allocate). */ static inline -FILE *bt_open_memstream(char **ptr, size_t *sizeloc) +FILE *bt_open_memstream(char **ptr __attribute__((unused)), + size_t *sizeloc __attribute__((unused))) { char *tmpname; FILE *fp; tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL); - if (_mktemp(tmpname) == NULL) { + if (!_mktemp(tmpname)) { goto error_free; } @@ -240,6 +228,8 @@ error_free: #else /* __MINGW32__ */ +#include + /* * Fallback for systems which don't have open_memstream. Create FILE * * with bt_open_memstream, but require call to @@ -247,7 +237,8 @@ error_free: * into the buffer (which we allocate). */ static inline -FILE *bt_open_memstream(char **ptr, size_t *sizeloc) +FILE *bt_open_memstream(char **ptr __attribute__((unused)), + size_t *sizeloc __attribute__((unused))) { char *tmpname; int ret; @@ -313,7 +304,7 @@ int bt_close_memstream(char **buf, size_t *size, FILE *fp) } *size = pos; /* add final \0 */ - *buf = calloc(pos + 1, sizeof(char)); + *buf = (char *) calloc(pos + 1, sizeof(char)); if (!*buf) { return -ENOMEM; }