From: Dan Carpenter <dan.carpenter@linaro.org>
To: Riyan Dhiman <riyandhiman14@gmail.com>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev
Subject: Re: [PATCH] staging: vme_user: Change slot number type from int to u32
Date: Mon, 26 Aug 2024 15:36:14 +0300 [thread overview]
Message-ID: <98a8d85e-9967-40df-8327-2fc03790b18e@stanley.mountain> (raw)
In-Reply-To: <CAAjz0QbrrPL73qz7OjZMi4banzZ+xE+WgOFHitRKtrsytQzD+Q@mail.gmail.com>
On Mon, Aug 26, 2024 at 05:18:57PM +0530, Riyan Dhiman wrote:
> >
> > Of course, there is a place for unsigned types in C but it's so subtle and
> > complicated to explain. I think people wish that there was a way to make C
> > safer when there really isn't. There is no easy answer like just declare
> > everything as u32. It's a false hope.
> >
>
> There is a function in the vme_user driver (vme.c:L715)
>
> unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int
> mask,
> unsigned int compare, unsigned int swap, loff_t offset)
> {
> struct vme_bridge *bridge = find_bridge(resource);
> struct vme_master_resource *image;
>
> if (!bridge->master_rmw) {
> dev_warn(bridge->parent, "Writing to resource not supported\n");
> return -EINVAL;
> }
>
> if (resource->type != VME_MASTER) {
> dev_err(bridge->parent, "Not a master resource\n");
> return -EINVAL;
> }
>
> image = list_entry(resource->entry, struct vme_master_resource, list);
>
> return bridge->master_rmw(image, mask, compare, swap, offset);
> }
> EXPORT_SYMBOL(vme_master_rmw);
>
> It is declared as unsigned everywhere but returns negative error codes.
> This is an issue,
> right? How should it be fixed? Do we need to change all the function
> declarations to int,
> or just in this function, since bridge->master_rmw returns an unsigned int?
Easy answer: Just delete vme_master_rmw() because nothing uses it.
Complicated answer: So long as the caller is saving it to int then it will work
okay. If it saves it to any other type then it will cause problems.
regards,
dan carpenter
prev parent reply other threads:[~2024-08-26 12:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-25 7:29 [PATCH] staging: vme_user: Change slot number type from int to u32 Riyan Dhiman
2024-08-25 7:50 ` Nam Cao
[not found] ` <CAAjz0QbOVn-M2uDnWVsh1AJjdN5d-AYsMkx3DjgaXVmS+SzARA@mail.gmail.com>
2024-08-25 9:40 ` Nam Cao
2024-08-26 6:34 ` Dan Carpenter
2024-08-26 7:28 ` Dan Carpenter
[not found] ` <CAAjz0QaWLcP=VGDd_1DzJiTZe3aX12spr_a4jWfo1pUTeZUtWQ@mail.gmail.com>
2024-08-26 12:31 ` Dan Carpenter
[not found] ` <CAAjz0QbrrPL73qz7OjZMi4banzZ+xE+WgOFHitRKtrsytQzD+Q@mail.gmail.com>
2024-08-26 12:36 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=98a8d85e-9967-40df-8327-2fc03790b18e@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=riyandhiman14@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox