platform_bionic/libc/include/sys/statvfs.h
Dan Albert baa2a973bd Use clang's nullability instead of nonnull.
http://clang.llvm.org/docs/AttributeReference.html#nonnull

_Nonnull is similar to the nonnull attribute in that it will instruct
compilers to warn the user if it can prove that a null argument is
being passed. Unlike the nonnull attribute, this annotation indicated
that a value *should not* be null, not that it *cannot* be null, or
even that the behavior is undefined. The important distinction is that
the optimizer will perform surprising optimizations like the
following:

    void foo(void*) __attribute__(nonnull, 1);

    int bar(int* p) {
      foo(p);

      // The following null check will be elided because nonnull
      // attribute means that, since we call foo with p, p can be
      // assumed to not be null. Thus this will crash if we are called
      // with a null pointer.
      if (src != NULL) {
        return *p;
      }
      return 0;
    }

    int main() {
      return bar(NULL);
    }

Note that by doing this we are no longer attaching any sort of
attribute for GCC (GCC doesn't support attaching nonnull directly to a
parameter, only to the function and naming the arguments
positionally). This means we won't be getting a warning for this case
from GCC any more. People that listen to warnings tend to use clang
anyway, and we're quickly moving toward that as the default, so this
seems to be an acceptable tradeoff.

Change-Id: Ie05fe7cec2f19a082c1defb303f82bcf9241b88d
2016-05-05 17:11:54 -07:00

71 lines
2 KiB
C

/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _SYS_STATVFS_H_
#define _SYS_STATVFS_H_
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS
#ifdef __LP64__
#define __STATVFS64_RESERVED uint32_t __f_reserved[6];
#else
#define __STATVFS64_RESERVED
#endif
#define __STATVFS64_BODY \
unsigned long f_bsize; \
unsigned long f_frsize; \
fsblkcnt_t f_blocks; \
fsblkcnt_t f_bfree; \
fsblkcnt_t f_bavail; \
fsfilcnt_t f_files; \
fsfilcnt_t f_ffree; \
fsfilcnt_t f_favail; \
unsigned long f_fsid; \
unsigned long f_flag; \
unsigned long f_namemax; \
__STATVFS64_RESERVED
struct statvfs { __STATVFS64_BODY };
struct statvfs64 { __STATVFS64_BODY };
#undef __STATVFS64_BODY
#undef __STATVFS64_RESERVED
#define ST_RDONLY 0x0001
#define ST_NOSUID 0x0002
#define ST_NODEV 0x0004
#define ST_NOEXEC 0x0008
#define ST_SYNCHRONOUS 0x0010
#define ST_MANDLOCK 0x0040
#define ST_NOATIME 0x0400
#define ST_NODIRATIME 0x0800
#define ST_RELATIME 0x1000
extern int statvfs(const char* __restrict _Nonnull, struct statvfs* __restrict _Nonnull)
__INTRODUCED_IN(21);
extern int statvfs64(const char* __restrict _Nonnull, struct statvfs64* __restrict _Nonnull)
__INTRODUCED_IN(21);
extern int fstatvfs(int, struct statvfs* _Nonnull) __INTRODUCED_IN(21);
extern int fstatvfs64(int, struct statvfs64* _Nonnull) __INTRODUCED_IN(21);
__END_DECLS
#endif /* _SYS_STATVFS_H_ */