All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: [sound:for-next 5/16] sound/core/rawmidi.c:1686:23: warning: Either the condition 'clock_type>=32' is redundant or the array 'clock_names[4]' is accessed at index 32, which is out of bounds. [arrayIndexOutOfBoundsCond]
Date: Tue, 18 May 2021 18:17:13 +0800	[thread overview]
Message-ID: <202105181800.gIna6IWs-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 8247 bytes --]

CC: kbuild-all(a)lists.01.org
CC: alsa-devel(a)alsa-project.org
TO: David Henningsson <coding@diwic.se>
CC: Takashi Iwai <tiwai@suse.de>
CC: Jaroslav Kysela <perex@perex.cz>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
head:   e8bfa15fefcd863c757240b6df15ca60d9b97997
commit: 08fdced60ca08e34e316a3ab945636fcdfcbc973 [5/16] ALSA: rawmidi: Add framing mode
:::::: branch date: 20 hours ago
:::::: commit date: 20 hours ago
compiler: nds32le-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> sound/core/rawmidi.c:1686:23: warning: Either the condition 'clock_type>=32' is redundant or the array 'clock_names[4]' is accessed at index 32, which is out of bounds. [arrayIndexOutOfBoundsCond]
              clock_names[clock_type]);
                         ^
   sound/core/rawmidi.c:1682:33: note: Assuming that condition 'clock_type>=32' is not redundant
        if (!snd_BUG_ON(clock_type >= sizeof(clock_names)))
                                   ^
   sound/core/rawmidi.c:1686:23: note: Array index out of bounds
              clock_names[clock_type]);
                         ^

vim +1686 sound/core/rawmidi.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  1612  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1613  /*
^1da177e4c3f41 Linus Torvalds    2005-04-16  1614   */
^1da177e4c3f41 Linus Torvalds    2005-04-16  1615  
48c9d417d7269d Takashi Iwai      2005-11-17  1616  static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
48c9d417d7269d Takashi Iwai      2005-11-17  1617  				       struct snd_info_buffer *buffer)
^1da177e4c3f41 Linus Torvalds    2005-04-16  1618  {
48c9d417d7269d Takashi Iwai      2005-11-17  1619  	struct snd_rawmidi *rmidi;
48c9d417d7269d Takashi Iwai      2005-11-17  1620  	struct snd_rawmidi_substream *substream;
48c9d417d7269d Takashi Iwai      2005-11-17  1621  	struct snd_rawmidi_runtime *runtime;
88a06d6fd6b369 Takashi Iwai      2020-12-06  1622  	unsigned long buffer_size, avail, xruns;
08fdced60ca08e David Henningsson 2021-05-15  1623  	unsigned int clock_type;
08fdced60ca08e David Henningsson 2021-05-15  1624  	static const char *clock_names[4] = { "none", "realtime", "monotonic", "monotonic raw" };
^1da177e4c3f41 Linus Torvalds    2005-04-16  1625  
^1da177e4c3f41 Linus Torvalds    2005-04-16  1626  	rmidi = entry->private_data;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1627  	snd_iprintf(buffer, "%s\n\n", rmidi->name);
1a60d4c5a0c402 Ingo Molnar       2006-01-16  1628  	mutex_lock(&rmidi->open_mutex);
^1da177e4c3f41 Linus Torvalds    2005-04-16  1629  	if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
9244b2c3079faa Johannes Berg     2006-10-05  1630  		list_for_each_entry(substream,
9244b2c3079faa Johannes Berg     2006-10-05  1631  				    &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams,
9244b2c3079faa Johannes Berg     2006-10-05  1632  				    list) {
^1da177e4c3f41 Linus Torvalds    2005-04-16  1633  			snd_iprintf(buffer,
^1da177e4c3f41 Linus Torvalds    2005-04-16  1634  				    "Output %d\n"
^1da177e4c3f41 Linus Torvalds    2005-04-16  1635  				    "  Tx bytes     : %lu\n",
^1da177e4c3f41 Linus Torvalds    2005-04-16  1636  				    substream->number,
^1da177e4c3f41 Linus Torvalds    2005-04-16  1637  				    (unsigned long) substream->bytes);
^1da177e4c3f41 Linus Torvalds    2005-04-16  1638  			if (substream->opened) {
7584af10cf46e0 Clemens Ladisch   2009-11-10  1639  				snd_iprintf(buffer,
7584af10cf46e0 Clemens Ladisch   2009-11-10  1640  				    "  Owner PID    : %d\n",
7584af10cf46e0 Clemens Ladisch   2009-11-10  1641  				    pid_vnr(substream->pid));
^1da177e4c3f41 Linus Torvalds    2005-04-16  1642  				runtime = substream->runtime;
88a06d6fd6b369 Takashi Iwai      2020-12-06  1643  				spin_lock_irq(&runtime->lock);
88a06d6fd6b369 Takashi Iwai      2020-12-06  1644  				buffer_size = runtime->buffer_size;
88a06d6fd6b369 Takashi Iwai      2020-12-06  1645  				avail = runtime->avail;
88a06d6fd6b369 Takashi Iwai      2020-12-06  1646  				spin_unlock_irq(&runtime->lock);
^1da177e4c3f41 Linus Torvalds    2005-04-16  1647  				snd_iprintf(buffer,
^1da177e4c3f41 Linus Torvalds    2005-04-16  1648  				    "  Mode         : %s\n"
^1da177e4c3f41 Linus Torvalds    2005-04-16  1649  				    "  Buffer size  : %lu\n"
^1da177e4c3f41 Linus Torvalds    2005-04-16  1650  				    "  Avail        : %lu\n",
^1da177e4c3f41 Linus Torvalds    2005-04-16  1651  				    runtime->oss ? "OSS compatible" : "native",
88a06d6fd6b369 Takashi Iwai      2020-12-06  1652  				    buffer_size, avail);
^1da177e4c3f41 Linus Torvalds    2005-04-16  1653  			}
^1da177e4c3f41 Linus Torvalds    2005-04-16  1654  		}
^1da177e4c3f41 Linus Torvalds    2005-04-16  1655  	}
^1da177e4c3f41 Linus Torvalds    2005-04-16  1656  	if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT) {
9244b2c3079faa Johannes Berg     2006-10-05  1657  		list_for_each_entry(substream,
9244b2c3079faa Johannes Berg     2006-10-05  1658  				    &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams,
9244b2c3079faa Johannes Berg     2006-10-05  1659  				    list) {
^1da177e4c3f41 Linus Torvalds    2005-04-16  1660  			snd_iprintf(buffer,
^1da177e4c3f41 Linus Torvalds    2005-04-16  1661  				    "Input %d\n"
^1da177e4c3f41 Linus Torvalds    2005-04-16  1662  				    "  Rx bytes     : %lu\n",
^1da177e4c3f41 Linus Torvalds    2005-04-16  1663  				    substream->number,
^1da177e4c3f41 Linus Torvalds    2005-04-16  1664  				    (unsigned long) substream->bytes);
^1da177e4c3f41 Linus Torvalds    2005-04-16  1665  			if (substream->opened) {
7584af10cf46e0 Clemens Ladisch   2009-11-10  1666  				snd_iprintf(buffer,
7584af10cf46e0 Clemens Ladisch   2009-11-10  1667  					    "  Owner PID    : %d\n",
7584af10cf46e0 Clemens Ladisch   2009-11-10  1668  					    pid_vnr(substream->pid));
^1da177e4c3f41 Linus Torvalds    2005-04-16  1669  				runtime = substream->runtime;
88a06d6fd6b369 Takashi Iwai      2020-12-06  1670  				spin_lock_irq(&runtime->lock);
88a06d6fd6b369 Takashi Iwai      2020-12-06  1671  				buffer_size = runtime->buffer_size;
88a06d6fd6b369 Takashi Iwai      2020-12-06  1672  				avail = runtime->avail;
88a06d6fd6b369 Takashi Iwai      2020-12-06  1673  				xruns = runtime->xruns;
88a06d6fd6b369 Takashi Iwai      2020-12-06  1674  				spin_unlock_irq(&runtime->lock);
^1da177e4c3f41 Linus Torvalds    2005-04-16  1675  				snd_iprintf(buffer,
^1da177e4c3f41 Linus Torvalds    2005-04-16  1676  					    "  Buffer size  : %lu\n"
^1da177e4c3f41 Linus Torvalds    2005-04-16  1677  					    "  Avail        : %lu\n"
^1da177e4c3f41 Linus Torvalds    2005-04-16  1678  					    "  Overruns     : %lu\n",
88a06d6fd6b369 Takashi Iwai      2020-12-06  1679  					    buffer_size, avail, xruns);
08fdced60ca08e David Henningsson 2021-05-15  1680  				if (substream->framing == SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP) {
08fdced60ca08e David Henningsson 2021-05-15  1681  					clock_type = substream->clock_type >> SNDRV_RAWMIDI_MODE_CLOCK_SHIFT;
08fdced60ca08e David Henningsson 2021-05-15  1682  					if (!snd_BUG_ON(clock_type >= sizeof(clock_names)))
08fdced60ca08e David Henningsson 2021-05-15  1683  						snd_iprintf(buffer,
08fdced60ca08e David Henningsson 2021-05-15  1684  							    "  Framing      : tstamp\n"
08fdced60ca08e David Henningsson 2021-05-15  1685  							    "  Clock type   : %s\n",
08fdced60ca08e David Henningsson 2021-05-15 @1686  							    clock_names[clock_type]);
08fdced60ca08e David Henningsson 2021-05-15  1687  				}
^1da177e4c3f41 Linus Torvalds    2005-04-16  1688  			}
^1da177e4c3f41 Linus Torvalds    2005-04-16  1689  		}
^1da177e4c3f41 Linus Torvalds    2005-04-16  1690  	}
1a60d4c5a0c402 Ingo Molnar       2006-01-16  1691  	mutex_unlock(&rmidi->open_mutex);
^1da177e4c3f41 Linus Torvalds    2005-04-16  1692  }
^1da177e4c3f41 Linus Torvalds    2005-04-16  1693  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

                 reply	other threads:[~2021-05-18 10: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=202105181800.gIna6IWs-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.