source: rtems/cpukit/score/src/coremsgbroadcast.c @ 2c050633

Last change on this file since 2c050633 was 2c050633, checked in by Sebastian Huber <sebastian.huber@…>, on 01/28/21 at 13:50:11

score: Simplify _CORE_message_queue_Broadcast()

This fix relates to a Coverity issue (PW.SET_BUT_NOT_USED).

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSScoreMessageQueue
5 *
6 * @brief This source file contains the implementation of
7 *   _CORE_message_queue_Broadcast().
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2008.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <rtems/score/coremsgimpl.h>
24#include <rtems/score/objectimpl.h>
25
26Status_Control _CORE_message_queue_Broadcast(
27  CORE_message_queue_Control *the_message_queue,
28  const void                 *buffer,
29  size_t                      size,
30  uint32_t                   *count,
31  Thread_queue_Context       *queue_context
32)
33{
34  uint32_t number_broadcasted;
35
36  if ( size > the_message_queue->maximum_message_size ) {
37    _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
38    return STATUS_MESSAGE_INVALID_SIZE;
39  }
40
41  number_broadcasted = 0;
42
43  _CORE_message_queue_Acquire_critical( the_message_queue, queue_context );
44
45  while (
46    _CORE_message_queue_Dequeue_receiver(
47      the_message_queue,
48      buffer,
49      size,
50      0,
51      queue_context
52    ) != NULL
53  ) {
54    number_broadcasted += 1;
55
56    _CORE_message_queue_Acquire( the_message_queue, queue_context );
57  }
58
59  _CORE_message_queue_Release( the_message_queue, queue_context );
60
61  *count = number_broadcasted;
62  return STATUS_SUCCESSFUL;
63}
Note: See TracBrowser for help on using the repository browser.