linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: mhalcrow@google.com
Cc: linux-ext4@vger.kernel.org
Subject: re: ext4 crypto: filename encryption modifications
Date: Tue, 12 May 2015 15:17:14 +0300	[thread overview]
Message-ID: <20150512121713.GA31379@mwanda> (raw)

Hello Michael Halcrow,

The patch 1f3862b5575b: "ext4 crypto: filename encryption
modifications" from Apr 12, 2015, leads to the following static
checker warning:

	fs/ext4/namei.c:1269 ext4_search_dir()
	warn: bool is not less than zero.

fs/ext4/namei.c
  1264          while ((char *) de < dlimit) {
  1265                  /* this code is executed quadratically often */
  1266                  /* do minimal checking `by hand' */
  1267                  if ((char *) de + de->name_len <= dlimit) {
  1268                          res = ext4_match(fname, de);
  1269                          if (res < 0) {
                                    ^^^^^^^
The comments for ext4_match() say it only returns zero and one.

 * NOTE! unlike strncmp, ext4_match returns 1 for success, 0 for failure.

So you could just do "if (ext4_match(fname, de)) {".

  1270                                  res = -1;
  1271                                  goto return_result;
  1272                          }
  1273                          if (res > 0) {
  1274                                  /* found a match - just to be sure, do
  1275                                   * a full check */
  1276                                  if (ext4_check_dir_entry(dir, NULL, de, bh,
  1277                                                  bh->b_data,
  1278                                                   bh->b_size, offset)) {
  1279                                          res = -1;
  1280                                          goto return_result;
  1281                                  }
  1282                                  *res_dir = de;
  1283                                  res = 1;
  1284                                  goto return_result;
  1285                          }

regards,
dan carpenter

                 reply	other threads:[~2015-05-12 12:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20150512121713.GA31379@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=mhalcrow@google.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;
as well as URLs for NNTP newsgroup(s).