public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org,
	Ivaylo Dimitrov <freemangordon@abv.bg>,
	pavel@ucw.cz, pali.rohar@gmail.com
Subject: Re: [PATCH] Staging: tidspbridge: Use hashtable implementation
Date: Mon, 6 Jan 2014 00:18:04 +0300	[thread overview]
Message-ID: <20140105211804.GG5443@mwanda> (raw)
In-Reply-To: <52C9AAB3.6050300@gmail.com>

This is not really an issue with this patch, it's something from the
original code so it doesn't affect merging the patch.

On Sun, Jan 05, 2014 at 08:55:47PM +0200, Ivaylo Dimitrov wrote:
> >Again, reverse the IS_ERR() check and return directly.  Use the struct
> >pointer instead of the address of the first member.
> >
> >	sym = gh_find(lib->sym_tab, (char *)name);
> >	if (IS_ERR(sym))
> >		return NULL;
> >
> >	return (struct dbll_symbol *)sym;
> >
> >That way is easier to read.  gh_find() should accept const pointers btw,
> >we shouldn't have to cast away the const in each of the callers.
> I don't think it is a good idea to return the structdbll_symbol*
> here - the function return type is structdynload_symbol* not
> structdbll_symbol*.

Oops.

> And that will break if we exchange value and name members of
> structdbll_symbol.

It will break anyway if we do that.  It's one of those things where you
can't worry too much about what crazy people might try to do later and
then no one reviews the code and no one tests it.  If we start doing
that sort of thing we are screwed already so it's not worth worrying
about.

I feel like the types in this driver are not beautiful.

The names are not clear.  Take "struct dbll_tar_obj" for example.  I'm
not clear what "dbll_" means.  I think the "d" stands for dynmic.  What
information does the "_obj" add?  It would be better to call it
"struct dbll_target".

"dbll_alloc" is a verb instead of a noun so it sounds like a function
not a struct.

But mostly there is too much nonsense casting throughout.
dbll_find_symbol() takes a struct dynamic_loader_sym pointer but we
immediatly cast it to struct ldr_symbol.  The struct ldr_symbol is
defined as:

struct ldr_symbol {
	struct dynamic_loader_sym dl_symbol;
        struct dbll_library_obj *lib;
};

The reason it does this is because it was originally C++ code and it
was ported to C.  I think we could move the "lib pointer to the end
of the "dynamic_loader_sym" struct.  We could make it a "void *data".
That would remove a source of casting.

There is a lot of this kind of stuff going on:

	struct dbll_library_obj *zl_lib = (struct dbll_library_obj *)lib;

"lib" is already a dbll_library_obj struct.  And "lib" is a better name,
what does zl_lib mean?  I think it's Hungarian notation which we don't
like.  Sometimes it uses pzl_ and I think the "p" means pointer.  Ugh.
Inside of functions then we don't need to prefix local variables.  It's
only for global variables where you run into naming clashes.

Anyway...  This driver needs a lot of fixing where data types are
concerned.

regards,
dan carpenter


      parent reply	other threads:[~2014-01-05 21:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-25 17:29 [PATCH] Staging: tidspbridge: Use hashtable implementation Ivaylo DImitrov
2013-12-27  9:45 ` Pavel Machek
2013-12-27 15:58   ` [PATCH v2] " Ivaylo Dimitrov
2014-01-02 15:00     ` Dan Carpenter
2014-01-02 13:46 ` [PATCH] " Dan Carpenter
     [not found]   ` <52C9AAB3.6050300@gmail.com>
2014-01-05 18:58     ` [PATCH v2] " Ivaylo Dimitrov
2014-01-05 19:47       ` Dan Carpenter
2014-01-05 23:14         ` Ivaylo Dimitrov
2014-01-05 23:17         ` [PATCH v3] " Ivaylo Dimitrov
2014-01-05 21:18     ` 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=20140105211804.GG5443@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=freemangordon@abv.bg \
    --cc=gregkh@linuxfoundation.org \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    --cc=pavel@ucw.cz \
    /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