考虑以下函数:
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;
}
我不认为我在它上面的函数中缺少一些花括号等。