Merge lp:~brianaker/drizzle/clang-support into lp:drizzle

Proposed by Brian Aker
Status: Merged
Approved by: Brian Aker
Approved revision: no longer in the source branch.
Merged at revision: 2581
Proposed branch: lp:~brianaker/drizzle/clang-support
Merge into: lp:drizzle
Diff against target: 243 lines (+69/-2)
12 files modified
bootstrap.sh (+44/-0)
client/drizzletest.cc (+4/-0)
drizzled/field/datetime.cc (+1/-0)
drizzled/filesort.cc (+1/-0)
drizzled/function/time/unix_timestamp.cc (+1/-0)
drizzled/sql_insert.cc (+3/-0)
drizzled/sql_load.cc (+1/-0)
drizzled/sql_union.cc (+3/-0)
drizzled/table/cache.cc (+1/-0)
drizzled/table_function_container.cc (+1/-0)
plugin/logging_query/logging_query.cc (+1/-0)
plugin/schema_engine/schema.cc (+8/-2)
To merge this branch: bzr merge lp:~brianaker/drizzle/clang-support
Reviewer Review Type Date Requested Status
Drizzle Trunk Pending
Review via email: mp+118033@code.launchpad.net
To post a comment you must log in.
lp:~brianaker/drizzle/clang-support updated
2579. By Drizzle Continuous Integration

added:
  bootstrap.sh
modified:
  client/drizzletest.cc
  drizzled/field/datetime.cc
  drizzled/filesort.cc
  drizzled/function/time/unix_timestamp.cc
  drizzled/sql_insert.cc
  drizzled/sql_load.cc
  drizzled/sql_union.cc
  drizzled/table/cache.cc
  drizzled/table_function_container.cc
  plugin/logging_query/logging_query.cc
  plugin/schema_engine/schema.cc
pending merge tips: (use -v to see all merge revisions)
  Brian Aker 2012-08-02 Add bootstrap script, and fixes for clang.

2580. By Brian Aker

Fixing license on bootsrap.sh file

Revision history for this message
Olaf van der Spek (olafvdspek) wrote :

> (void)(ret);

Is stuff like this really necessary?

Revision history for this message
Mark Atwood (fallenpegasus) wrote :

On Sat, Aug 4, 2012 at 6:31 AM, Olaf van der Spek <email address hidden> wrote:
>> (void)(ret);
>
> Is stuff like this really necessary?

Do have clang compile without warnings, yes it is.

Otherwise the dataflow analyzer in clang determines that the data
result is unused, and issues a warning.

..m

Revision history for this message
Olaf van der Spek (olafvdspek) wrote :

Isn't it used in the assert expression?

Revision history for this message
Mark Atwood (fallenpegasus) wrote :

On Sat, Aug 4, 2012 at 9:39 AM, Olaf van der Spek <email address hidden> wrote:
> Isn't it used in the assert expression?

Expressions in assert() are not expanded or evaluated when NDEBUG is defined.

It is a bug to assume that assert() will evaluate, and it's most
certainly a bug to have an assert() expression that has a side
effect.

A good dataflow analyzer knows that assert() should not count as "data
used". Given that clang's DFA is pretty close to state of the
research art, I would guess that it also knows that.

Back when I was programming in Ada, the compiler I was using could
optimize assertation statements, making them test only occasionally,
only on entrance and exit of the loop they where in, only when
something "interesting" happened in the data flow, and so forth.

..m

Revision history for this message
Olaf van der Spek (olafvdspek) wrote :

I'm aware of assert semantics. But (void)(ret); doesn't generate any code either. Having to use (void) for all data that's only used in assert expressions doesn't seem (entirely) right.

lp:~brianaker/drizzle/clang-support updated
2581. By Brian Aker

Fix type in shell.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'bootstrap.sh'
--- bootstrap.sh 1970-01-01 00:00:00 +0000
+++ bootstrap.sh 2012-08-11 15:59:19 +0000
@@ -0,0 +1,44 @@
1#!/bin/bash
2#
3# Copyright (C) 2012 Brian Aker
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met:
9#
10# * Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12#
13# * Redistributions in binary form must reproduce the above
14# copyright notice, this list of conditions and the following disclaimer
15# in the documentation and/or other materials provided with the
16# distribution.
17#
18# * The names of its contributors may not be used to endorse or
19# promote products derived from this software without specific prior
20# written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34if test -f configure; then make clean; make merge-clean; make distclean; fi;
35
36rm -r -f autom4te.cache/ config.h config.log config.status
37./config/autorun.sh
38if [ $(uname) = "Darwin" ];
39then
40 ./configure CC=clang CXX=clang++ --enable-assert
41else
42 ./configure --enable-assert
43fi
44make
045
=== modified file 'client/drizzletest.cc'
--- client/drizzletest.cc 2012-02-12 06:10:39 +0000
+++ client/drizzletest.cc 2012-08-11 15:59:19 +0000
@@ -734,6 +734,10 @@
734 break;734 break;
735 }735 }
736 assert(known_arg_type);736 assert(known_arg_type);
737 if (known_arg_type == false)
738 {
739 die("Bad argument");
740 }
737741
738 /* Check required arg */742 /* Check required arg */
739 if (arg->ds->length() == 0 && arg->required)743 if (arg->ds->length() == 0 && arg->required)
740744
=== modified file 'drizzled/field/datetime.cc'
--- drizzled/field/datetime.cc 2011-06-20 15:04:56 +0000
+++ drizzled/field/datetime.cc 2012-08-11 15:59:19 +0000
@@ -138,6 +138,7 @@
138 size_t tmp_string_len;138 size_t tmp_string_len;
139139
140 tmp_string_len= temporal.to_string(tmp_string, type::Time::MAX_STRING_LENGTH);140 tmp_string_len= temporal.to_string(tmp_string, type::Time::MAX_STRING_LENGTH);
141 (void)(tmp_string_len);
141 assert(tmp_string_len < type::Time::MAX_STRING_LENGTH);142 assert(tmp_string_len < type::Time::MAX_STRING_LENGTH);
142 my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp_string);143 my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp_string);
143 return 1;144 return 1;
144145
=== modified file 'drizzled/filesort.cc'
--- drizzled/filesort.cc 2011-10-24 11:55:49 +0000
+++ drizzled/filesort.cc 2012-08-11 15:59:19 +0000
@@ -859,6 +859,7 @@
859 from= tmp_buffer;859 from= tmp_buffer;
860 }860 }
861 tmp_length= cs->strnxfrm(to,sort_field->length, (unsigned char*) from, length);861 tmp_length= cs->strnxfrm(to,sort_field->length, (unsigned char*) from, length);
862 (void)(tmp_length);
862 assert(tmp_length == sort_field->length);863 assert(tmp_length == sort_field->length);
863 }864 }
864 else865 else
865866
=== modified file 'drizzled/function/time/unix_timestamp.cc'
--- drizzled/function/time/unix_timestamp.cc 2011-04-08 13:16:30 +0000
+++ drizzled/function/time/unix_timestamp.cc 2012-08-11 15:59:19 +0000
@@ -70,6 +70,7 @@
70 char buff[DateTime::MAX_STRING_LENGTH];70 char buff[DateTime::MAX_STRING_LENGTH];
71 int buff_len;71 int buff_len;
72 buff_len= temporal.to_string(buff, DateTime::MAX_STRING_LENGTH);72 buff_len= temporal.to_string(buff, DateTime::MAX_STRING_LENGTH);
73 (void)(buff_len);
73 assert((buff_len+1) < DateTime::MAX_STRING_LENGTH);74 assert((buff_len+1) < DateTime::MAX_STRING_LENGTH);
74 my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(0), buff);75 my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(0), buff);
75 return 0;76 return 0;
7677
=== modified file 'drizzled/sql_insert.cc'
--- drizzled/sql_insert.cc 2012-02-12 08:49:06 +0000
+++ drizzled/sql_insert.cc 2012-08-11 15:59:19 +0000
@@ -456,6 +456,7 @@
456 if (session->transaction.stmt.hasModifiedNonTransData())456 if (session->transaction.stmt.hasModifiedNonTransData())
457 session->transaction.all.markModifiedNonTransData();457 session->transaction.all.markModifiedNonTransData();
458 }458 }
459 (void)(transactional_table);
459 assert(transactional_table || !changed || session->transaction.stmt.hasModifiedNonTransData());460 assert(transactional_table || !changed || session->transaction.stmt.hasModifiedNonTransData());
460461
461 }462 }
@@ -1394,6 +1395,8 @@
13941395
1395 changed= (info.copied || info.deleted || info.updated);1396 changed= (info.copied || info.deleted || info.updated);
1396 transactional_table= table->cursor->has_transactions();1397 transactional_table= table->cursor->has_transactions();
1398 (void)(transactional_table);
1399 (void)(changed);
1397 assert(transactional_table || !changed ||1400 assert(transactional_table || !changed ||
1398 session->transaction.stmt.hasModifiedNonTransData());1401 session->transaction.stmt.hasModifiedNonTransData());
1399 table->cursor->ha_release_auto_increment();1402 table->cursor->ha_release_auto_increment();
14001403
=== modified file 'drizzled/sql_load.cc'
--- drizzled/sql_load.cc 2012-07-11 14:06:00 +0000
+++ drizzled/sql_load.cc 2012-08-11 15:59:19 +0000
@@ -412,6 +412,7 @@
412412
413 session->my_ok(info.copied + info.deleted, 0, 0L, msg);413 session->my_ok(info.copied + info.deleted, 0, 0L, msg);
414err:414err:
415 (void)(transactional_table);
415 assert(transactional_table || !(info.copied || info.deleted) ||416 assert(transactional_table || !(info.copied || info.deleted) ||
416 session->transaction.stmt.hasModifiedNonTransData());417 session->transaction.stmt.hasModifiedNonTransData());
417 table->cursor->ha_release_auto_increment();418 table->cursor->ha_release_auto_increment();
418419
=== modified file 'drizzled/sql_union.cc'
--- drizzled/sql_union.cc 2011-08-05 13:28:48 +0000
+++ drizzled/sql_union.cc 2012-08-11 15:59:19 +0000
@@ -294,7 +294,9 @@
294 information about fields lengths and exact types294 information about fields lengths and exact types
295 */295 */
296 if (!is_union_select)296 if (!is_union_select)
297 {
297 types= first_sl->item_list;298 types= first_sl->item_list;
299 }
298 else if (sl == first_sl)300 else if (sl == first_sl)
299 {301 {
300 /*302 /*
@@ -303,6 +305,7 @@
303 The main reason of this is that we can't create305 The main reason of this is that we can't create
304 field object without table.306 field object without table.
305 */307 */
308 (void)(empty_table);
306 assert(!empty_table);309 assert(!empty_table);
307 empty_table= (Table*) session->mem.calloc(sizeof(Table));310 empty_table= (Table*) session->mem.calloc(sizeof(Table));
308 types.clear();311 types.clear();
309312
=== modified file 'drizzled/table/cache.cc'
--- drizzled/table/cache.cc 2011-07-06 22:48:32 +0000
+++ drizzled/table/cache.cc 2012-08-11 15:59:19 +0000
@@ -283,6 +283,7 @@
283void Cache::insert(table::Concurrent* arg)283void Cache::insert(table::Concurrent* arg)
284{284{
285 CacheMap::iterator returnable= cache.insert(std::make_pair(arg->getShare()->getCacheKey(), arg));285 CacheMap::iterator returnable= cache.insert(std::make_pair(arg->getShare()->getCacheKey(), arg));
286 (void)(returnable);
286 assert(returnable != cache.end());287 assert(returnable != cache.end());
287}288}
288289
289290
=== modified file 'drizzled/table_function_container.cc'
--- drizzled/table_function_container.cc 2011-07-05 15:59:49 +0000
+++ drizzled/table_function_container.cc 2012-08-11 15:59:19 +0000
@@ -45,6 +45,7 @@
45void TableFunctionContainer::addFunction(plugin::TableFunction *tool)45void TableFunctionContainer::addFunction(plugin::TableFunction *tool)
46{46{
47 std::pair<ToolMap::iterator, bool> ret= table_map.insert(std::make_pair(tool->getPath(), tool));47 std::pair<ToolMap::iterator, bool> ret= table_map.insert(std::make_pair(tool->getPath(), tool));
48 (void)(ret);
48 assert(ret.second);49 assert(ret.second);
49}50}
5051
5152
=== modified file 'plugin/logging_query/logging_query.cc'
--- plugin/logging_query/logging_query.cc 2012-06-20 14:17:30 +0000
+++ plugin/logging_query/logging_query.cc 2012-08-11 15:59:19 +0000
@@ -374,6 +374,7 @@
374374
375 // a single write has a kernel thread lock, thus no need mutex guard this375 // a single write has a kernel thread lock, thus no need mutex guard this
376 wrv= write(fd, msgbuf.c_str(), msgbuf.length());376 wrv= write(fd, msgbuf.c_str(), msgbuf.length());
377 (void)(wrv);
377 assert(wrv == msgbuf.length());378 assert(wrv == msgbuf.length());
378379
379 return false;380 return false;
380381
=== modified file 'plugin/schema_engine/schema.cc'
--- plugin/schema_engine/schema.cc 2012-07-11 14:06:00 +0000
+++ plugin/schema_engine/schema.cc 2012-08-11 15:59:19 +0000
@@ -102,6 +102,7 @@
102 pair<SchemaCache::iterator, bool> ret=102 pair<SchemaCache::iterator, bool> ret=
103 schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));103 schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
104104
105 (void)(ret);
105 assert(ret.second); // If this has happened, something really bad is going down.106 assert(ret.second); // If this has happened, something really bad is going down.
106 }107 }
107 }108 }
@@ -121,7 +122,9 @@
121 drizzled::message::catalog::shared_ptr message;122 drizzled::message::catalog::shared_ptr message;
122123
123 if (not entry->filename.compare(GLOBAL_TEMPORARY_EXT))124 if (not entry->filename.compare(GLOBAL_TEMPORARY_EXT))
125 {
124 continue;126 continue;
127 }
125128
126 drizzled::identifier::Catalog identifier(entry->filename);129 drizzled::identifier::Catalog identifier(entry->filename);
127130
@@ -176,7 +179,7 @@
176 schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));179 schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
177180
178 assert(ret.second); // If this has happened, something really bad is going down.181 assert(ret.second); // If this has happened, something really bad is going down.
179 return true;182 return ret.second;
180}183}
181184
182bool Schema::doDropSchema(const identifier::Schema &schema_identifier)185bool Schema::doDropSchema(const identifier::Schema &schema_identifier)
@@ -222,7 +225,9 @@
222 schema_message.name());225 schema_message.name());
223226
224 if (access(schema_identifier.getPath().c_str(), F_OK))227 if (access(schema_identifier.getPath().c_str(), F_OK))
228 {
225 return false;229 return false;
230 }
226231
227 if (writeSchemaFile(schema_identifier, schema_message))232 if (writeSchemaFile(schema_identifier, schema_message))
228 {233 {
@@ -233,9 +238,10 @@
233 schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));238 schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
234239
235 assert(ret.second); // If this has happened, something really bad is going down.240 assert(ret.second); // If this has happened, something really bad is going down.
241 return ret.second;
236 }242 }
237243
238 return true;244 return false;
239}245}
240246
241/**247/**

Subscribers

People subscribed via source and target branches

to all changes: