考虑以下功能:
off_t
func (const struct inode *inode)
{
off_t length = 0;
read_cache (&length, inode->sector, offsetof (struct inode_disk, length), sizeof (off_t));
return length;
}
我同时收到错误和警告:
error: expected declaration or statement at end of input
warning: control reaches end of non-void function [-Wreturn-type]
错误和警告指向的行是控制函数右括号的最后一行。
当我搜索时,我发现当函数的返回类型为非void时,会出现此错误,并且我们没有返回任何内容。 但这不是这种情况。
请帮忙!
编辑:
以下函数包含该函数以及源代码中出现的函数:
/* Re-enables writes to INODE.
Must be called once by each inode opener who has called
inode_deny_write() on the inode, before closing the inode. */
void
inode_allow_write (struct inode *inode)
{
ASSERT (inode->deny_write_cnt > 0);
ASSERT (inode->deny_write_cnt <= inode->open_cnt);
inode->deny_write_cnt--;
}
/* Returns the length, in bytes, of INODE's data. */
off_t
inode_length (const struct inode *inode)
{
off_t length = 0;
read_cache (&length, inode->sector, offsetof (struct inode_disk, length), sizeof (off_t));
return length;
}
我不认为我在它上面的功能上缺少一些大括号等。