Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdd1d2d3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro
Browse files

fs: fix kernel_read prototype



Use proper ssize_t and size_t types for the return value and count
argument, move the offset last and make it an in/out argument like
all other read/write helpers, and make the buf argument a void pointer
to get rid of lots of casts in the callers.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c41fbad0
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf,
	bool elf32;
	u32 flags;
	int ret;
	loff_t pos;

	elf32 = ehdr->e32.e_ident[EI_CLASS] == ELFCLASS32;
	flags = elf32 ? ehdr->e32.e_flags : ehdr->e64.e_flags;
@@ -108,21 +109,16 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf,

		if (phdr32->p_filesz < sizeof(abiflags))
			return -EINVAL;

		ret = kernel_read(elf, phdr32->p_offset,
				  (char *)&abiflags,
				  sizeof(abiflags));
		pos = phdr32->p_offset;
	} else {
		if (phdr64->p_type != PT_MIPS_ABIFLAGS)
			return 0;
		if (phdr64->p_filesz < sizeof(abiflags))
			return -EINVAL;

		ret = kernel_read(elf, phdr64->p_offset,
				  (char *)&abiflags,
				  sizeof(abiflags));
		pos = phdr64->p_offset;
	}

	ret = kernel_read(elf, &abiflags, sizeof(abiflags), &pos);
	if (ret < 0)
		return ret;
	if (ret != sizeof(abiflags))
+2 −2
Original line number Diff line number Diff line
@@ -407,10 +407,10 @@ static int load_aout_library(struct file *file)
	unsigned long bss, start_addr, len, error;
	int retval;
	struct exec ex;

	loff_t pos = 0;

	retval = -ENOEXEC;
	error = kernel_read(file, 0, (char *) &ex, sizeof(ex));
	error = kernel_read(file, &ex, sizeof(ex), &pos);
	if (error != sizeof(ex))
		goto out;

+5 −8
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ static int cx25821_get_audio_data(struct cx25821_dev *dev,
		p = (char *)dev->_audiodata_buf_virt_addr + frame_offset;

	for (i = 0; i < dev->_audio_lines_count; i++) {
		int n = kernel_read(file, file_offset, mybuf, AUDIO_LINE_SIZE);
		int n = kernel_read(file, mybuf, AUDIO_LINE_SIZE, &file_offset);
		if (n < AUDIO_LINE_SIZE) {
			pr_info("Done: exit %s() since no more bytes to read from Audio file\n",
				__func__);
@@ -290,7 +290,6 @@ static int cx25821_get_audio_data(struct cx25821_dev *dev,
			memcpy(p, mybuf, n);
			p += n;
		}
		file_offset += n;
	}
	dev->_audioframe_count++;
	fput(file);
@@ -318,7 +317,7 @@ static int cx25821_openfile_audio(struct cx25821_dev *dev,
{
	char *p = (void *)dev->_audiodata_buf_virt_addr;
	struct file *file;
	loff_t offset;
	loff_t file_offset = 0;
	int i, j;

	file = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0);
@@ -328,11 +327,11 @@ static int cx25821_openfile_audio(struct cx25821_dev *dev,
		return PTR_ERR(file);
	}

	for (j = 0, offset = 0; j < NUM_AUDIO_FRAMES; j++) {
	for (j = 0; j < NUM_AUDIO_FRAMES; j++) {
		for (i = 0; i < dev->_audio_lines_count; i++) {
			char buf[AUDIO_LINE_SIZE];
			int n = kernel_read(file, offset, buf,
						AUDIO_LINE_SIZE);
			loff_t offset = file_offset;
			int n = kernel_read(file, buf, AUDIO_LINE_SIZE, &file_offset);

			if (n < AUDIO_LINE_SIZE) {
				pr_info("Done: exit %s() since no more bytes to read from Audio file\n",
@@ -344,8 +343,6 @@ static int cx25821_openfile_audio(struct cx25821_dev *dev,

			if (p)
				memcpy(p + offset, buf, n);

			offset += n;
		}
		dev->_audioframe_count++;
	}
+1 −1
Original line number Diff line number Diff line
@@ -1379,7 +1379,7 @@ static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_
	if (err)
		return err;
	noreclaim_flag = memalloc_noreclaim_save();
	tx = kernel_read(file, pos, buf, count);
	tx = kernel_read(file, buf, count, &pos);
	memalloc_noreclaim_restore(noreclaim_flag);
	put_pages(ns);
	return tx;
+2 −1
Original line number Diff line number Diff line
@@ -341,11 +341,12 @@ static int load_aout_library(struct file *file)
	unsigned long error;
	int retval;
	struct exec ex;
	loff_t pos = 0;

	inode = file_inode(file);

	retval = -ENOEXEC;
	error = kernel_read(file, 0, (char *) &ex, sizeof(ex));
	error = kernel_read(file, &ex, sizeof(ex), &pos);
	if (error != sizeof(ex))
		goto out;

Loading