| File: | obj-scan-build/libdiskfs/../../libdiskfs/io-write.c |
| Location: | line 59, column 3 |
| Description: | Value stored to 'err' is never read |
| 1 | /* |
| 2 | Copyright (C) 1994,95,96,97,2001 Free Software Foundation, Inc. |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU General Public License as |
| 6 | published by the Free Software Foundation; either version 2, or (at |
| 7 | your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, but |
| 10 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 17 | |
| 18 | #include "priv.h" |
| 19 | #include "io_S.h" |
| 20 | #include <fcntl.h> |
| 21 | |
| 22 | /* Implement io_write as described in <hurd/io.defs>. */ |
| 23 | kern_return_t |
| 24 | diskfs_S_io_write (struct protid *cred, |
| 25 | char *data, |
| 26 | mach_msg_type_number_t datalen, |
| 27 | off_t offset, |
| 28 | mach_msg_type_number_t *amt) |
| 29 | { |
| 30 | struct node *np; |
| 31 | error_t err; |
| 32 | off_t off = offset; |
| 33 | |
| 34 | if (!cred) |
| 35 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); |
| 36 | |
| 37 | np = cred->po->np; |
| 38 | if (!(cred->po->openstat & O_WRITE0x0002)) |
| 39 | return EBADF((0x10 << 26) | ((9) & 0x3fff)); |
| 40 | |
| 41 | pthread_mutex_lock (&np->lock); |
| 42 | |
| 43 | assert (!S_ISDIR(np->dn_stat.st_mode))((!((((np->dn_stat.st_mode)) & 0170000) == (0040000))) ? (void) (0) : __assert_fail ("!((((np->dn_stat.st_mode)) & 0170000) == (0040000))" , "../../libdiskfs/io-write.c", 43, __PRETTY_FUNCTION__)); |
| 44 | |
| 45 | iohelp_get_conch (&np->conch); |
| 46 | |
| 47 | if (off == -1) |
| 48 | { |
| 49 | if (cred->po->openstat & O_APPEND0x0100) |
| 50 | cred->po->filepointer = np->dn_stat.st_size; |
| 51 | off = cred->po->filepointer; |
| 52 | } |
| 53 | if (off < 0) |
| 54 | { |
| 55 | err = EINVAL((0x10 << 26) | ((22) & 0x3fff)); |
| 56 | goto out; |
| 57 | } |
| 58 | |
| 59 | err = 0; |
Value stored to 'err' is never read | |
| 60 | while (off + (off_t) datalen > np->allocsize) |
| 61 | { |
| 62 | err = diskfs_grow (np, off + datalen, cred); |
| 63 | if (diskfs_synchronous) |
| 64 | diskfs_node_update (np, 1); |
| 65 | if (err) |
| 66 | goto out; |
| 67 | if (np->filemod_reqs) |
| 68 | diskfs_notice_filechange (np, FILE_CHANGED_EXTEND, 0, off + datalen); |
| 69 | } |
| 70 | |
| 71 | if (off + (off_t) datalen > np->dn_stat.st_size) |
| 72 | { |
| 73 | np->dn_stat.st_size = off + datalen; |
| 74 | np->dn_set_ctime = 1; |
| 75 | if (diskfs_synchronous) |
| 76 | diskfs_node_update (np, 1); |
| 77 | } |
| 78 | |
| 79 | *amt = datalen; |
| 80 | err = _diskfs_rdwr_internal (np, data, off, amt, 1, 0); |
| 81 | |
| 82 | if (!err && offset == -1) |
| 83 | cred->po->filepointer += *amt; |
| 84 | |
| 85 | if (!err |
| 86 | && ((cred->po->openstat & O_FSYNC0x0400) || diskfs_synchronous)) |
| 87 | diskfs_file_update (np, 1); |
| 88 | |
| 89 | if (!err && np->filemod_reqs) |
| 90 | diskfs_notice_filechange (np, FILE_CHANGED_WRITE, off, off + *amt); |
| 91 | out: |
| 92 | pthread_mutex_unlock (&np->lock); |
| 93 | return err; |
| 94 | } |