functionSource
stringlengths
20
97.4k
CWE-119
bool
2 classes
CWE-120
bool
2 classes
CWE-469
bool
2 classes
CWE-476
bool
2 classes
CWE-other
bool
2 classes
combine
int64
0
1
ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw) { s32 status = 0; u16 autoneg_reg = IXGBE_MII_AUTONEG_REG; bool autoneg = false; ixgbe_link_speed speed; ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg); if (speed & IXGBE_LINK_SPEED_10GB_FULL) { /* Set or unset auto-negotiation 10G advertisement */ hw->phy.ops.read_reg(hw, MDIO_AN_10GBT_CTRL, MDIO_MMD_AN, &autoneg_reg); autoneg_reg &= ~MDIO_AN_10GBT_CTRL_ADV10G; if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL) autoneg_reg |= MDIO_AN_10GBT_CTRL_ADV10G; hw->phy.ops.write_reg(hw, MDIO_AN_10GBT_CTRL, MDIO_MMD_AN, autoneg_reg); } if (speed & IXGBE_LINK_SPEED_1GB_FULL) { /* Set or unset auto-negotiation 1G advertisement */ hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG, MDIO_MMD_AN, &autoneg_reg); autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE; if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE; hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG, MDIO_MMD_AN, autoneg_reg); } if (speed & IXGBE_LINK_SPEED_100_FULL) { /* Set or unset auto-negotiation 100M advertisement */ hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE, MDIO_MMD_AN, &autoneg_reg); autoneg_reg &= ~(ADVERTISE_100FULL | ADVERTISE_100HALF); if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL) autoneg_reg |= ADVERTISE_100FULL; hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE, MDIO_MMD_AN, autoneg_reg); } /* Blocked by MNG FW so don't reset PHY */ if (ixgbe_check_reset_blocked(hw)) return 0; /* Restart PHY autonegotiation and wait for completion */ hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_AN, &autoneg_reg); autoneg_reg |= MDIO_AN_CTRL1_RESTART; hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_AN, autoneg_reg); return status; }
false
false
false
false
false
0
carl9170_init_phy(struct ar9170 *ar, enum ieee80211_band band) { int i, err; u32 val; bool is_2ghz = band == IEEE80211_BAND_2GHZ; bool is_40mhz = conf_is_ht40(&ar->hw->conf); carl9170_regwrite_begin(ar); for (i = 0; i < ARRAY_SIZE(ar5416_phy_init); i++) { if (is_40mhz) { if (is_2ghz) val = ar5416_phy_init[i]._2ghz_40; else val = ar5416_phy_init[i]._5ghz_40; } else { if (is_2ghz) val = ar5416_phy_init[i]._2ghz_20; else val = ar5416_phy_init[i]._5ghz_20; } carl9170_regwrite(ar5416_phy_init[i].reg, val); } carl9170_regwrite_finish(); err = carl9170_regwrite_result(); if (err) return err; err = carl9170_init_phy_from_eeprom(ar, is_2ghz, is_40mhz); if (err) return err; err = carl9170_init_power_cal(ar); if (err) return err; if (!ar->fw.hw_counters) { err = carl9170_write_reg(ar, AR9170_PWR_REG_PLL_ADDAC, is_2ghz ? 0x5163 : 0x5143); } return err; }
false
false
false
false
false
0
compare_ids(u_int8_t *id1, u_int8_t *id2, size_t idlen) { int id1_type, id2_type; id1_type = GET_ISAKMP_ID_TYPE(id1); id2_type = GET_ISAKMP_ID_TYPE(id2); return id1_type == id2_type ? memcmp(id1 + ISAKMP_ID_DATA_OFF, id2 + ISAKMP_ID_DATA_OFF, idlen - ISAKMP_ID_DATA_OFF) : -1; }
false
false
false
false
false
0
read_data(char *buf, int *result, unsigned int max_size) { int i; int status; // Temporary hack; read one character at a time so that // we don't lose track of which line we're reading. max_size = 1; // Invoke the read callback status = input_callback(buf, max_size, input_callback_handle); parse_assert(status >= 0, "error while reading from input"); if (status == 0) { // End of file *result = YY_NULL; } else { // Check for newlines // TODO: stop at the first newline, so we don't // lose track of the line we're on for (i=0; i<status; ++i) { if (buf[i] == '\n') { ++line_num; } } *result = status; } }
false
false
false
false
false
0
excludeItems(QHash<QString,KService::Ptr>& items1, const QHash<QString,KService::Ptr>& items2) { foreach (const KService::Ptr &p, items2) items1.remove(p->menuId()); }
false
false
false
false
false
0
net_write(UPSCONN_t *ups, const char *buf, size_t buflen) { int ret; #ifdef WITH_SSL if (ups->ssl) { #ifdef WITH_OPENSSL ret = SSL_write(ups->ssl, buf, buflen); #elif defined(WITH_NSS) /* WITH_OPENSSL */ ret = PR_Write(ups->ssl, buf, buflen); #endif /* WITH_OPENSSL | WITH_NSS */ if (ret < 1) { ups->upserror = UPSCLI_ERR_SSLERR; } return ret; } #endif ret = upscli_select_write(ups->fd, buf, buflen, 0, 0); /* error writing data, server disconnected? */ if (ret < 0) { ups->upserror = UPSCLI_ERR_WRITE; ups->syserrno = errno; } /* not ready for writing, server disconnected? */ if (ret == 0) { ups->upserror = UPSCLI_ERR_SRVDISC; } return ret; }
false
false
false
false
false
0
gdl_dock_master_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { GdlDockMaster *master = GDL_DOCK_MASTER (object); switch (prop_id) { case PROP_DEFAULT_TITLE: g_value_set_string (value, master->priv->default_title); break; case PROP_LOCKED: g_value_set_int (value, COMPUTE_LOCKED (master)); break; case PROP_SWITCHER_STYLE: g_value_set_enum (value, master->priv->switcher_style); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
false
false
false
false
false
0
H5P_set_multi_type(H5P_genplist_t *plist, H5FD_mem_t type) { herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5P_set_multi_type, FAIL); if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { if(H5P_set(plist, H5F_ACS_MULTI_TYPE_NAME, &type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL,"can't set type for multi driver"); } else { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access or data transfer property list"); } done: FUNC_LEAVE_NOAPI(ret_value); }
false
false
false
false
false
0
construct_linear_table(struct table *table, const struct linear_element *strings, long size) { long i; table->size = size; table->strings = gw_malloc(size * (sizeof table->strings[0])); table->numbers = NULL; table->versions = gw_malloc(size * (sizeof table->versions[0])); table->linear = 1; for (i = 0; i < size; i++) { table->strings[i] = octstr_imm(strings[i].str); table->versions[i] = strings[i].version; } }
false
false
false
false
false
0
FFCEUX_PPURead_Default(uint32 A) { uint32 tmp = A; if (PPU_hook) PPU_hook(A); if (tmp < 0x2000) { return VPage[tmp >> 10][tmp]; } else if (tmp < 0x3F00) { return vnapage[(tmp >> 10) & 0x3][tmp & 0x3FF]; } else { uint8 ret; if (!(tmp & 3)) { if (!(tmp & 0xC)) ret = PALRAM[0x00]; else ret = UPALRAM[((tmp & 0xC) >> 2) - 1]; } else ret = PALRAM[tmp & 0x1F]; if (GRAYSCALE) ret &= 0x30; return ret; } }
false
false
false
false
false
0
test_read_wrong_master (Test *test, gconstpointer unused) { GkmDataResult res; GkmSecret *master; master = gkm_secret_new_from_password ("wrong"); gkm_secret_data_set_master (test->sdata, master); g_object_unref (master); res = check_read_keyring_file (test, SRCDIR "/files/encrypted.keyring"); g_assert (res == GKM_DATA_LOCKED); }
false
false
false
false
false
0
qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Q_ASSERT(staticMetaObject.cast(_o)); QGeoAreaMonitor *_t = static_cast<QGeoAreaMonitor *>(_o); switch (_id) { case 0: _t->areaEntered((*reinterpret_cast< const QGeoPositionInfo(*)>(_a[1]))); break; case 1: _t->areaExited((*reinterpret_cast< const QGeoPositionInfo(*)>(_a[1]))); break; default: ; } } }
false
false
false
false
false
0
_non_existent() { if( _NP_is_nil() ) _CORBA_invoked_nil_pseudo_ref(); omni_tracedmutex_lock sync(pd_lock); return pd_destroyed ? 1 : 0; }
false
false
false
false
false
0
btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset) { struct extent_map *em; struct map_lookup *map; struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; int readonly = 0; int miss_ndevs = 0; int i; read_lock(&map_tree->map_tree.lock); em = lookup_extent_mapping(&map_tree->map_tree, chunk_offset, 1); read_unlock(&map_tree->map_tree.lock); if (!em) return 1; map = (struct map_lookup *)em->bdev; for (i = 0; i < map->num_stripes; i++) { if (map->stripes[i].dev->missing) { miss_ndevs++; continue; } if (!map->stripes[i].dev->writeable) { readonly = 1; goto end; } } /* * If the number of missing devices is larger than max errors, * we can not write the data into that chunk successfully, so * set it readonly. */ if (miss_ndevs > btrfs_chunk_max_errors(map)) readonly = 1; end: free_extent_map(em); return readonly; }
false
false
false
false
false
0
rb_mod_include_p(mod, mod2) VALUE mod; VALUE mod2; { VALUE p; Check_Type(mod2, T_MODULE); for (p = RCLASS(mod)->super; p; p = RCLASS(p)->super) { if (BUILTIN_TYPE(p) == T_ICLASS) { if (RBASIC(p)->klass == mod2) return Qtrue; } } return Qfalse; }
false
false
false
false
false
0
init_mem(compress_io *cio, FILE *in_fp, int in_size, FILE *out_fp, int out_size) { cio->in = (mem_mgr *) malloc(sizeof(mem_mgr)); if (!cio->in) err_exit(BUFFER_ALLOC_ERR); cio->in->set = (UINT8 *) malloc(sizeof(UINT8) * in_size); if (!cio->in->set) err_exit(BUFFER_ALLOC_ERR); cio->in->pos = cio->in->set; cio->in->end = cio->in->set + in_size; cio->in->flush_buffer = flush_cin_buffer; cio->in->fp = in_fp; cio->out = (mem_mgr *) malloc(sizeof(mem_mgr)); if (!cio->out) err_exit(BUFFER_ALLOC_ERR); cio->out->set = (UINT8 *) malloc(sizeof(UINT8) * out_size); if (!cio->out->set) err_exit(BUFFER_ALLOC_ERR); cio->out->pos = cio->out->set; cio->out->end = cio->out->set + out_size; cio->out->flush_buffer = flush_cout_buffer; cio->out->fp = out_fp; cio->temp_bits.len = 0; cio->temp_bits.val = 0; }
false
true
false
true
false
1
unparse_WKT(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar* serialized, allocator alloc, freeor free, int flags) { LWDEBUGF(2, "unparse_WKT called with parser flags %d.", flags); if (serialized==NULL) return 0; /* Setup the inital parser flags and empty the return struct */ current_lwg_unparser_result = lwg_unparser_result; current_unparser_check_flags = flags; lwg_unparser_result->wkoutput = NULL; lwg_unparser_result->size = 0; lwg_unparser_result->serialized_lwgeom = serialized; unparser_ferror_occured = 0; local_malloc=alloc; local_free=free; len = 128; out_start = out_pos = alloc(len); lwgi=0; output_wkt(serialized, 0); /* Store the result in the struct */ lwg_unparser_result->wkoutput = out_start; lwg_unparser_result->size = strlen(out_start); return unparser_ferror_occured; }
false
false
false
false
false
0
Disturbance(real lon, real& deltax, real& deltay, real& deltaz) const throw() { real clam, slam, M[Geocentric::dim2_]; CircularEngine::cossin(lon, clam, slam); real Tres = InternalT(clam, slam, deltax, deltay, deltaz, true, true); Geocentric::Rotation(_sphi, _cphi, slam, clam, M); Geocentric::Unrotate(M, deltax, deltay, deltaz, deltax, deltay, deltaz); return Tres; }
false
false
false
false
false
0
mailimap_struct_list_send(mailstream * fd, clist * list, char symbol, mailimap_struct_sender * sender) { clistiter * cur; void * elt; int r; cur = clist_begin(list); if (cur == NULL) return MAILIMAP_NO_ERROR; elt = clist_content(cur); r = (* sender)(fd, elt); if (r != MAILIMAP_NO_ERROR) return r; cur = clist_next(cur); while (cur != NULL) { r = mailimap_char_send(fd, symbol); if (r != MAILIMAP_NO_ERROR) return r; elt = clist_content(cur); r = (* sender)(fd, elt); if (r != MAILIMAP_NO_ERROR) return r; cur = clist_next(cur); } return MAILIMAP_NO_ERROR; }
false
false
false
false
false
0
mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list) { struct mei_device *dev; struct mei_msg_data *buf; struct mei_msg_hdr mei_hdr; size_t len; u32 msg_slots; int slots; int rets; bool first_chunk; if (WARN_ON(!cl || !cl->dev)) return -ENODEV; dev = cl->dev; buf = &cb->buf; first_chunk = cb->buf_idx == 0; rets = first_chunk ? mei_cl_flow_ctrl_creds(cl) : 1; if (rets < 0) return rets; if (rets == 0) { cl_dbg(dev, cl, "No flow control credentials: not sending.\n"); return 0; } slots = mei_hbuf_empty_slots(dev); len = buf->size - cb->buf_idx; msg_slots = mei_data2slots(len); mei_hdr.host_addr = mei_cl_host_addr(cl); mei_hdr.me_addr = mei_cl_me_id(cl); mei_hdr.reserved = 0; mei_hdr.internal = cb->internal; if (slots >= msg_slots) { mei_hdr.length = len; mei_hdr.msg_complete = 1; /* Split the message only if we can write the whole host buffer */ } else if (slots == dev->hbuf_depth) { msg_slots = slots; len = (slots * sizeof(u32)) - sizeof(struct mei_msg_hdr); mei_hdr.length = len; mei_hdr.msg_complete = 0; } else { /* wait for next time the host buffer is empty */ return 0; } cl_dbg(dev, cl, "buf: size = %d idx = %lu\n", cb->buf.size, cb->buf_idx); rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx); if (rets) { cl->status = rets; list_move_tail(&cb->list, &cmpl_list->list); return rets; } cl->status = 0; cl->writing_state = MEI_WRITING; cb->buf_idx += mei_hdr.length; cb->completed = mei_hdr.msg_complete == 1; if (first_chunk) { if (mei_cl_flow_ctrl_reduce(cl)) return -EIO; } if (mei_hdr.msg_complete) list_move_tail(&cb->list, &dev->write_waiting_list.list); return 0; }
false
false
false
false
false
0
Execute(const std::string &cmd, ExecuteFlags flags) throw() { int ret = -1; try { // use simpler system() calls whenever we don't want to capture // output, because it means that output is sent to the user // directly if (((flags & EXECUTE_NO_STDERR) || !LogRedirect::redirectingStderr()) && ((flags & EXECUTE_NO_STDOUT) || !LogRedirect::redirectingStdout())) { string fullcmd = cmd; if (flags & EXECUTE_NO_STDERR) { fullcmd += " 2>/dev/null"; } if (flags & EXECUTE_NO_STDOUT) { fullcmd += " >/dev/null"; } SE_LOG_DEBUG(NULL, "running command via system(): %s", cmd.c_str()); ret = system(fullcmd.c_str()); } else { // Need to catch at least one of stdout or stderr. A // low-tech solution would be to use temporary files which // are read after system() returns. But we want true // streaming of the output, so use fork()/exec() plus // reliable output redirection. SE_LOG_DEBUG(NULL, "running command via fork/exec with output redirection: %s", cmd.c_str()); LogRedirect io(flags); pid_t child = fork(); switch (child) { case 0: { // child process: // - close unused end of the pipes if (io.getStdout().m_read >= 0) { close(io.getStdout().m_read); } if (io.getStderr().m_read >= 0) { close(io.getStderr().m_read); } // - replace file descriptors 1 and 2 with the ones // prepared for us or /dev/null int fd; int fd_null = open("/dev/null", O_WRONLY); fd = io.getStdout().m_write; if (fd <= 0) { fd = fd_null; } dup2(fd, STDOUT_FILENO); fd = io.getStderr().m_write; if (fd <= 0) { fd = fd_null; } dup2(fd, STDERR_FILENO); // - run command execl("/bin/sh", "sh", "-c", cmd.c_str(), NULL); // - error handling if execl() failed (= returned) std::cerr << cmd << ": execl() failed: " << strerror(errno); exit(1); break; } case -1: // error handling in parent when fork() fails SE_LOG_ERROR(NULL, "%s: fork() failed: %s", cmd.c_str(), strerror(errno)); break; default: // parent: // - close write side so that we can detect "end of data" if (io.getStdout().m_write >= 0) { close(io.getStdout().m_write); } if (io.getStderr().m_write >= 0) { close(io.getStderr().m_write); } // - read until no more data or error triggers exception io.process(); // - wait for child, without caring about errors waitpid(child, &ret, 0); break; } } } catch (...) { Exception::handle(); } return ret; }
false
false
false
false
false
0
sparse_matvec( sparse_matrix *A, double *x, double *b ) { int i, j, itr_j; for( i = 0; i < n; ++i ) b[i] = eta[ atom->type[i] ] * x[i]; for( i = n; i < N; ++i ) b[i] = 0; for( i = 0; i < n; ++i ) { for( itr_j=A->firstnbr[i]; itr_j<A->firstnbr[i]+A->numnbrs[i]; itr_j++) { j = A->jlist[itr_j]; b[i] += A->val[itr_j] * x[j]; b[j] += A->val[itr_j] * x[i]; } } }
false
false
false
false
false
0
realloc(CVmVarHeapHybrid_hdr *mem, size_t siz, CVmObject *obj) { void *new_mem; /* * if the new block fits in our cell size, return the original * memory unchanged; note that we must adjust the pointer so that we * return the client-visible portion */ if (siz <= cell_size_) return (void *)(mem + 1); /* * The memory won't fit in our cell size, so not only can't we * re-use the existing cell, but we can't allocate the memory from * our own sub-block at all. Allocate an entirely new block from * the heap manager. */ new_mem = mem_mgr_->alloc_mem(siz, obj); /* * Copy the old cell's contents to the new memory. Note that the * user-visible portion of the old cell starts immediately after the * header; don't copy the old header, since it's not applicable to * the new object. Note also that we got a pointer directly to the * user-visible portion of the new object, so we don't need to make * any adjustments to the new pointer. */ memcpy(new_mem, (void *)(mem + 1), cell_size_); /* free the old memory */ free(mem); /* return the new memory */ return new_mem; }
false
false
false
false
false
0
ndma_session_distribute_quantum (struct ndm_session *sess) { int total_did_something = 0; int did_something; do { did_something = 0; did_something |= ndmis_quantum (sess); #ifndef NDMOS_OPTION_NO_TAPE_AGENT if (sess->tape_acb.mover_state.state != NDMP9_MOVER_STATE_IDLE) did_something |= ndmta_quantum (sess); #endif /* !NDMOS_OPTION_NO_TAPE_AGENT */ #ifndef NDMOS_OPTION_NO_DATA_AGENT if (sess->data_acb.data_state.state != NDMP9_DATA_STATE_IDLE) did_something |= ndmda_quantum (sess); #endif /* !NDMOS_OPTION_NO_DATA_AGENT */ total_did_something |= did_something; } while (did_something); return total_did_something; }
false
false
false
false
false
0
GetInetAddr(char *host) { struct in_addr addr; struct hostent *hp; addr.s_addr = inet_addr(host); if ((addr.s_addr == INADDR_NONE) || (addr.s_addr == 0)) { if ((hp = gethostbyname(host)) == 0) { snprintf(OUTPUT,CF_BUFSIZE,"\nhost not found: %s\n",host); FatalError(OUTPUT); } if (hp->h_addrtype != AF_INET) { snprintf(OUTPUT,CF_BUFSIZE,"unexpected address family: %d\n",hp->h_addrtype); FatalError(OUTPUT); } if (hp->h_length != sizeof(addr)) { snprintf(OUTPUT,CF_BUFSIZE,"unexpected address length %d\n",hp->h_length); FatalError(OUTPUT); } memcpy((char *) &addr, hp->h_addr, hp->h_length); } return (addr.s_addr); }
false
false
false
true
false
1
scalar_clone(eval_scalar *result, const eval_scalar *s) { switch (s->type) { case SCALAR_INT: { *result = *s; break; } case SCALAR_STR: { *result = *s; result->scalar.str.value = ht_malloc(result->scalar.str.len); memcpy(result->scalar.str.value, s->scalar.str.value, result->scalar.str.len); break; } case SCALAR_FLOAT: { *result = *s; break; } default: break; } }
false
false
false
false
false
0
localTime(const Date& date, hourTy h, minuteTy m, secondTy s) /* Return a local Time for the specified Standard Time date, hour, minute, and second. */ { clockTy t = (seconds_in_day*(date-refDate) + 60L*60L*h + 60L*m + s); if ( !date.between(refDate,maxDate) || (TIME_ZONE < 0 && t < -TIME_ZONE) ) fprintf(stderr,"Date range error %d %s %d\n", date.dayOfMonth(),date.nameOfMonth(),date.year()); return Time(t); }
false
false
false
false
false
0
sca3000_rb_allocate(struct iio_dev *indio_dev) { struct iio_buffer *buf; struct iio_hw_buffer *ring; ring = kzalloc(sizeof(*ring), GFP_KERNEL); if (!ring) return NULL; ring->private = indio_dev; buf = &ring->buf; buf->stufftoread = 0; buf->length = 64; buf->attrs = sca3000_ring_attributes; iio_buffer_init(buf); return buf; }
false
false
false
false
false
0
_e_gadcon_client_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) { Evas_Event_Mouse_Up *ev; E_Gadcon_Client *gcc; ev = event_info; gcc = data; if ((ev->button == 1) && (gcc->gadcon->instant_edit)) { if (gcc->instant_edit_timer) { ecore_timer_del(gcc->instant_edit_timer); gcc->instant_edit_timer = NULL; } if (gcc->o_control) { _e_gadcon_client_move_stop(gcc); e_gadcon_client_edit_end(gcc); } } else if (ev->button == 2) { if (gcc->o_control) { _e_gadcon_client_move_stop(gcc); e_gadcon_client_edit_end(gcc); } } }
false
false
false
false
false
0
init_wrap(int argc, char **argv) { struct init_options opt; int ret; int optidx = 0; struct getargs args[] = { { "realm-max-ticket-life", 0, arg_string, NULL, "realm max ticket lifetime", NULL }, { "realm-max-renewable-life", 0, arg_string, NULL, "realm max renewable lifetime", NULL }, { "bare", 0, arg_flag, NULL, "only create krbtgt for realm", NULL }, { "help", 'h', arg_flag, NULL, NULL, NULL } }; int help_flag = 0; opt.realm_max_ticket_life_string = NULL; opt.realm_max_renewable_life_string = NULL; opt.bare_flag = 0; args[0].value = &opt.realm_max_ticket_life_string; args[1].value = &opt.realm_max_renewable_life_string; args[2].value = &opt.bare_flag; args[3].value = &help_flag; if(getarg(args, 4, argc, argv, &optidx)) goto usage; if(argc - optidx < 1) { fprintf(stderr, "Arguments given (%u) are less than expected (1).\n\n", argc - optidx); goto usage; } if(help_flag) goto usage; ret = init(&opt, argc - optidx, argv + optidx); return ret; usage: arg_printusage (args, 4, "init", "realm..."); return 0; }
false
false
false
false
false
0
get_genl_kind(char *str) { void *dlh; char buf[256]; struct genl_util *f; for (f = genl_list; f; f = f->next) if (strcmp(f->name, str) == 0) return f; snprintf(buf, sizeof(buf), "%s.so", str); dlh = dlopen(buf, RTLD_LAZY); if (dlh == NULL) { dlh = BODY; if (dlh == NULL) { dlh = BODY = dlopen(NULL, RTLD_LAZY); if (dlh == NULL) goto noexist; } } snprintf(buf, sizeof(buf), "%s_genl_util", str); f = dlsym(dlh, buf); if (f == NULL) goto noexist; reg: f->next = genl_list; genl_list = f; return f; noexist: f = malloc(sizeof(*f)); if (f) { memset(f, 0, sizeof(*f)); strncpy(f->name, str, 15); f->parse_genlopt = parse_nofopt; f->print_genlopt = print_nofopt; goto reg; } return f; }
false
false
false
false
false
0
_chm_parse_UTF8(UChar **pEntry, UInt64 count, char *path) { /* XXX: implement UTF-8 support, including a real mapping onto * ISO-8859-1? probably there is a library to do this? As is * immediately apparent from the below code, I'm presently not doing * any special handling for files in which none of the strings contain * UTF-8 multi-byte characters. */ while (count != 0) { *path++ = (char)(*(*pEntry)++); --count; } *path = '\0'; return 1; }
false
false
false
false
false
0
gcr_simple_certificate_new (const guchar *data, gsize n_data) { GcrSimpleCertificate *cert; g_return_val_if_fail (data, NULL); g_return_val_if_fail (n_data, NULL); cert = g_object_new (GCR_TYPE_SIMPLE_CERTIFICATE, NULL); cert->pv->data = cert->pv->owned = g_memdup (data, n_data); cert->pv->n_data = n_data; return GCR_CERTIFICATE (cert); }
false
false
false
false
false
0
FormatTimeInMillisAsSeconds(TimeInMillis ms) { ::std::stringstream ss; ss << ms/1000.0; return ss.str(); }
false
false
false
false
false
0
checkAlignmentRadioButtons() { static std::map<LyXAlignment, QString> labelMap_; if (labelMap_.empty()) { labelMap_[LYX_ALIGN_BLOCK] = qt_("Justified"); labelMap_[LYX_ALIGN_LEFT] = qt_("Left"); labelMap_[LYX_ALIGN_RIGHT] = qt_("Right"); labelMap_[LYX_ALIGN_CENTER] = qt_("Center"); } RadioMap::iterator it = radioMap_.begin(); for (; it != radioMap_.end(); ++it) { LyXAlignment const align = it->first; it->second->setEnabled(align & alignPossible()); } if (haveMultiParSelection()) alignDefaultRB->setText(alignDefaultLabel_); else alignDefaultRB->setText(alignDefaultLabel_ + " (" + labelMap_[alignDefault()] + ")"); }
false
false
false
false
false
0
speedportReconnect( struct sProfile *psProfile ) { struct sUrlHandler *psHandler; gchar anUrl[ BUF_SIZE ]; gint nError = -1; if( routerLogin( psProfile ) != 0 ) { return nError; } /* Disconnect */ snprintf( anUrl, sizeof( anUrl ), "%s%s/cgi-bin/webcm", getRouterProtocol( psProfile ), routerGetHost( psProfile ) ); psHandler = urlHandler( anUrl, getRouterPort( psProfile ) ); setPostData( psHandler, "connection0:settings/cmd_disconnect=1" ); nError = readUrl( psHandler, psProfile ); freeHandler( psHandler ); /* Connect */ snprintf( anUrl, sizeof( anUrl ), "%s%s/cgi-bin/webcm", getRouterProtocol( psProfile ), routerGetHost( psProfile ) ); psHandler = urlHandler( anUrl, getRouterPort( psProfile ) ); setPostData( psHandler, "connection0:settings/cmd_connect=1" ); nError = readUrl( psHandler, psProfile ); freeHandler( psHandler ); return nError; }
false
false
false
false
false
0
ast_cdr_dup(struct ast_cdr *cdr) { struct ast_cdr *newcdr; if (!cdr) /* don't die if we get a null cdr pointer */ return NULL; newcdr = ast_cdr_alloc(); if (!newcdr) return NULL; memcpy(newcdr, cdr, sizeof(*newcdr)); /* The varshead is unusable, volatile even, after the memcpy so we take care of that here */ memset(&newcdr->varshead, 0, sizeof(newcdr->varshead)); ast_cdr_copy_vars(newcdr, cdr); newcdr->next = NULL; return newcdr; }
false
false
false
false
false
0
musb_g_init_endpoints(struct musb *musb) { u8 epnum; struct musb_hw_ep *hw_ep; unsigned count = 0; /* initialize endpoint list just once */ INIT_LIST_HEAD(&(musb->g.ep_list)); for (epnum = 0, hw_ep = musb->endpoints; epnum < musb->nr_endpoints; epnum++, hw_ep++) { if (hw_ep->is_shared_fifo /* || !epnum */) { init_peripheral_ep(musb, &hw_ep->ep_in, epnum, 0); count++; } else { if (hw_ep->max_packet_sz_tx) { init_peripheral_ep(musb, &hw_ep->ep_in, epnum, 1); count++; } if (hw_ep->max_packet_sz_rx) { init_peripheral_ep(musb, &hw_ep->ep_out, epnum, 0); count++; } } } }
false
false
false
false
false
0
make_option_str_with_ver(char **argv,int argc, char *version){ char *op_str; int len=0; int i; for(i=0;i<argc;i++){ len += strlen(argv[i]); } len += (strlen(version) + 2); len += argc-1; op_str = (char *)malloc(sizeof(char)*(len+1)); if(op_str == NULL){ fatal("not enough memory\n"); } op_str[0] = '\0'; sprintf(op_str, "%s.%s ", argv[0], version); for(i=1;i<argc;i++){ strcat(op_str,argv[i]); if(argc > i+1){ strcat(op_str," "); } } return op_str; }
false
false
false
false
false
0
qla2x00_issue_marker(scsi_qla_host_t *vha, int ha_locked) { if (ha_locked) { if (__qla2x00_marker(vha, vha->req, vha->req->rsp, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) return QLA_FUNCTION_FAILED; } else { if (qla2x00_marker(vha, vha->req, vha->req->rsp, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) return QLA_FUNCTION_FAILED; } vha->marker_needed = 0; return QLA_SUCCESS; }
false
false
false
false
false
0
remove(const Identifier &name) { assert(!name.isNull()); checkConsistency(); UString::Rep *rep = name._ustring.rep(); UString::Rep *key; if (!m_usingTable) { #if USE_SINGLE_ENTRY key = m_singleEntryKey; if (rep == key) { key->deref(); m_singleEntryKey = 0; checkConsistency(); } #endif return; } // Find the thing to remove. unsigned h = rep->hash(); int sizeMask = m_u.table->sizeMask; Entry *entries = m_u.table->entries; int i = h & sizeMask; int k = 0; #if DUMP_STATISTICS ++numProbes; ++numRemoves; numCollisions += entries[i].key && entries[i].key != rep; #endif while ((key = entries[i].key)) { if (rep == key) break; if (k == 0) k = 1 | (h % sizeMask); i = (i + k) & sizeMask; #if DUMP_STATISTICS ++numRehashes; #endif } if (!key) return; // Replace this one element with the deleted sentinel. Also set value to 0 and attributes to DontEnum // to help callers that iterate all keys not have to check for the sentinel. key->deref(); key = deletedSentinel(); entries[i].key = key; entries[i].value = 0; entries[i].attributes = DontEnum; assert(m_u.table->keyCount >= 1); --m_u.table->keyCount; ++m_u.table->sentinelCount; if (m_u.table->sentinelCount * 4 >= m_u.table->size) rehash(); checkConsistency(); }
false
false
false
false
false
0
strbuffer (unsigned long size) { if (size > lbuffer.max) { /* ANSI "realloc" doesn't need this test, but some machines (Sun!) don't follow ANSI */ lbuffer.b = (lbuffer.b) ? realloc(lbuffer.b, lbuffer.max=size) : malloc(lbuffer.max=size); if (lbuffer.b == NULL) lua_error("memory overflow"); } return lbuffer.b; }
false
false
false
false
false
0
kFirstNode(state_t *s, int funct_nr, int argc, reg_t *argv) { list_t *l = LOOKUP_NULL_LIST(argv[0]); if (l && !sane_listp(s, argv[0])) SCIkwarn(SCIkERROR,"List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); if (l) return l->first; else return NULL_REG; }
false
false
false
false
false
0
soap_fdelete(struct soap_clist *p) { switch (p->type) { case SOAP_TYPE_ns__Object: if (p->size < 0) SOAP_DELETE((ns__Object*)p->ptr); else SOAP_DELETE_ARRAY((ns__Object*)p->ptr); break; case SOAP_TYPE_ns__Shape: if (p->size < 0) SOAP_DELETE((ns__Shape*)p->ptr); else SOAP_DELETE_ARRAY((ns__Shape*)p->ptr); break; case SOAP_TYPE_ns__Square: if (p->size < 0) SOAP_DELETE((ns__Square*)p->ptr); else SOAP_DELETE_ARRAY((ns__Square*)p->ptr); break; case SOAP_TYPE_ns__List: if (p->size < 0) SOAP_DELETE((ns__List*)p->ptr); else SOAP_DELETE_ARRAY((ns__List*)p->ptr); break; case SOAP_TYPE_ns__polytestResponse: if (p->size < 0) SOAP_DELETE((struct ns__polytestResponse*)p->ptr); else SOAP_DELETE_ARRAY((struct ns__polytestResponse*)p->ptr); break; case SOAP_TYPE_ns__polytest: if (p->size < 0) SOAP_DELETE((struct ns__polytest*)p->ptr); else SOAP_DELETE_ARRAY((struct ns__polytest*)p->ptr); break; #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Header: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Header*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Header*)p->ptr); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Code: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Code*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Code*)p->ptr); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Detail: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Detail*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Detail*)p->ptr); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Reason: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Reason*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Reason*)p->ptr); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Fault: if (p->size < 0) SOAP_DELETE((struct SOAP_ENV__Fault*)p->ptr); else SOAP_DELETE_ARRAY((struct SOAP_ENV__Fault*)p->ptr); break; #endif default: return SOAP_ERR; } return SOAP_OK; }
false
false
false
false
false
0
do_layer1(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point) { int clip = 0; unsigned int balloc[2 * SBLIMIT]; unsigned int scale_index[2][SBLIMIT]; real fraction[2][SBLIMIT]; struct frame *fr = &(mp->fr); int i, stereo = fr->stereo; int single = fr->single; fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : 32; if (stereo == 1 || single == 3) single = 0; I_step_one(mp, balloc, scale_index, fr); for (i = 0; i < SCALE_BLOCK; i++) { I_step_two(mp, fraction, balloc, scale_index, fr); if (single >= 0) { clip += synth_1to1_mono(mp, (real *) fraction[single], pcm_sample, pcm_point); } else { int p1 = *pcm_point; clip += synth_1to1(mp, (real *) fraction[0], 0, pcm_sample, &p1); clip += synth_1to1(mp, (real *) fraction[1], 1, pcm_sample, pcm_point); } } return clip; }
false
false
false
false
false
0
options_add_filter(obj_list_t *obj_list, int n_objs, filter_info_t filt, pack_opttbl_t *table ) { unsigned int i, I; int j, added=0, found=0; /* increase the size of the collection by N_OBJS if necessary */ if (table->nelems+n_objs >= table->size) { if (aux_inctable(table,n_objs)<0) return -1; } /* search if this object is already in the table; "path" is the key */ if (table->nelems>0) { /* go tru the supplied list of names */ for (j = 0; j < n_objs; j++) { /* linear table search */ for (i = 0; i < table->nelems; i++) { /*already on the table */ if (HDstrcmp(obj_list[j].obj,table->objs[i].path)==0) { /* insert */ aux_tblinsert_filter(table,i,filt); found=1; break; } /* if */ } /* i */ if (found==0) { /* keep the grow in a temp var */ I = table->nelems + added; added++; HDstrcpy(table->objs[I].path,obj_list[j].obj); aux_tblinsert_filter(table,I,filt); } /* cases where we have an already inserted name but there is a new name also example: -l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1 dset1 is already inserted, but dset2 must also be */ else if (found==1 && HDstrcmp(obj_list[j].obj,table->objs[i].path)!=0) { /* keep the grow in a temp var */ I = table->nelems + added; added++; HDstrcpy(table->objs[I].path,obj_list[j].obj); aux_tblinsert_filter(table,I,filt); } } /* j */ } /* first time insertion */ else { /* go tru the supplied list of names */ for (j = 0; j < n_objs; j++) { I = table->nelems + added; added++; HDstrcpy(table->objs[I].path,obj_list[j].obj); aux_tblinsert_filter(table,I,filt); } } table->nelems+= added; return 0; }
false
false
false
false
false
0
set_statusline_mode(VMG_ int mode) { CVmFormatterDisp *str; /* * if we're switching into statusline mode, and we don't have a * statusline stream yet, create one */ if (mode && statline_str_ == 0) { /* create and initialize the statusline stream */ statline_str_ = new CVmFormatterStatline(this); statline_str_->init(); } /* get the stream selected by the new mode */ if (mode) str = statline_str_; else str = main_disp_str_; /* if this is already the active stream, we have nothing more to do */ if (str == disp_str_) return; /* make the new stream current */ disp_str_ = str; /* * check which mode we're switching to, so we can do some extra work * specific to each mode */ if (mode) { /* * we're switching to the status line, so disable the log stream - * statusline text is never sent to the log, since the log reflects * only what was displayed in the main text area */ log_enabled_ = FALSE; } else { /* * we're switching back to the main stream, so flush the statusline * so we're sure the statusline text is displayed */ /* end the line */ statline_str_->format_text(vmg_ "\n", 1); /* flush output */ statline_str_->flush(vmg_ VM_NL_NONE); /* re-enable the log stream, if we have one */ if (log_str_ != 0) log_enabled_ = TRUE; } /* switch at the OS layer */ os_status(mode); }
false
false
false
false
false
0
php_libxml_clear_object(php_libxml_node_object *object TSRMLS_DC) { if (object->properties) { object->properties = NULL; } php_libxml_decrement_node_ptr(object TSRMLS_CC); return php_libxml_decrement_doc_ref(object TSRMLS_CC); }
false
false
false
false
false
0
matrix_row_sub_index(matrix_t *A, matrix_t *s) { int i, j, k; matrix_t *sub = matrix_alloc(s->nrows, A->ncols); k = 0; for (i = 0; i < A->nrows; ++i){ if(i == (int)s->data[k][0]) { for (j = 0; j < A->ncols; ++j) sub->data[k][j] = A->data[i][j]; ++k; if (k >= s->nrows) break; } } return sub; }
false
false
false
false
false
0
probe_lvm2(blkid_probe pr, const struct blkid_idmag *mag) { int sector = mag->kboff << 1; struct lvm2_pv_label_header *label; char uuid[LVM2_ID_LEN + 7]; unsigned char *buf; buf = blkid_probe_get_buffer(pr, mag->kboff << 10, 512 + sizeof(struct lvm2_pv_label_header)); if (!buf) return -1; /* buf is at 0k or 1k offset; find label inside */ if (memcmp(buf, "LABELONE", 8) == 0) { label = (struct lvm2_pv_label_header *) buf; } else if (memcmp(buf + 512, "LABELONE", 8) == 0) { label = (struct lvm2_pv_label_header *)(buf + 512); sector++; } else { return 1; } if (le64_to_cpu(label->sector_xl) != (unsigned) sector) return 1; if (lvm2_calc_crc(&label->offset_xl, LVM2_LABEL_SIZE - ((char *) &label->offset_xl - (char *) label)) != le32_to_cpu(label->crc_xl)) { DBG(DEBUG_PROBE, printf("LVM2: label checksum incorrect at sector %d\n", sector)); return 1; } format_lvm_uuid(uuid, (char *) label->pv_uuid); blkid_probe_sprintf_uuid(pr, label->pv_uuid, sizeof(label->pv_uuid), "%s", uuid); /* the mag->magic is the same string as label->type, * but zero terminated */ blkid_probe_set_version(pr, mag->magic); /* LVM (pvcreate) wipes begin of the device -- let's remember this * to resolve conflicts bettween LVM and partition tables, ... */ blkid_probe_set_wiper(pr, 0, 8 * 1024); return 0; }
false
false
false
false
false
0
snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ichdev) { int idx; u32 *bdbar = ichdev->bdbar; unsigned long port = ichdev->reg_offset; iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr); if (ichdev->size == ichdev->fragsize) { ichdev->ack_reload = ichdev->ack = 2; ichdev->fragsize1 = ichdev->fragsize >> 1; for (idx = 0; idx < (ICH_REG_LVI_MASK + 1) * 2; idx += 4) { bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf); bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */ ichdev->fragsize1 >> ichdev->pos_shift); bdbar[idx + 2] = cpu_to_le32(ichdev->physbuf + (ichdev->size >> 1)); bdbar[idx + 3] = cpu_to_le32(0x80000000 | /* interrupt on completion */ ichdev->fragsize1 >> ichdev->pos_shift); } ichdev->frags = 2; } else { ichdev->ack_reload = ichdev->ack = 1; ichdev->fragsize1 = ichdev->fragsize; for (idx = 0; idx < (ICH_REG_LVI_MASK + 1) * 2; idx += 2) { bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + (((idx >> 1) * ichdev->fragsize) % ichdev->size)); bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */ ichdev->fragsize >> ichdev->pos_shift); #if 0 dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n", idx + 0, bdbar[idx + 0], bdbar[idx + 1]); #endif } ichdev->frags = ichdev->size / ichdev->fragsize; } iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi = ICH_REG_LVI_MASK); ichdev->civ = 0; iputbyte(chip, port + ICH_REG_OFF_CIV, 0); ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags; ichdev->position = 0; #if 0 dev_dbg(chip->card->dev, "lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n", ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, ichdev->fragsize1); #endif /* clear interrupts */ iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); }
false
false
false
false
false
0
client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; rpc_clnt_procedure_t *proc = NULL; clnt_args_t args = {0,}; conf = this->private; if (!conf || !conf->fops) goto out; args.loc = loc; args.flags = flags; args.xattr = dict; args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_XATTROP]; if (!proc) { gf_log (this->name, GF_LOG_ERROR, "rpc procedure not found for %s", gf_fop_list[GF_FOP_XATTROP]); goto out; } if (proc->fn) ret = proc->fn (frame, this, &args); out: if (ret) STACK_UNWIND_STRICT (xattrop, frame, -1, ENOTCONN, NULL, NULL); return 0; }
false
false
false
false
false
0
PR_FreeAddrInfo(PRAddrInfo *ai) { #if defined(_PR_HAVE_GETADDRINFO) #if defined(_PR_INET6_PROBE) if (!_pr_ipv6_is_present()) PR_Free((PRAddrInfoFB *) ai); else #endif FREEADDRINFO((PRADDRINFO *) ai); #else PR_Free((PRAddrInfoFB *) ai); #endif }
false
false
false
false
false
0
uih_replayenable(struct uih_context *uih, xio_file f, xio_constpath filename, int animr) { struct uih_playcontext *p; const char *s; if (uih->play) { uih_error(uih, gettext("Replay is already active")); return 0; } if (f == XIO_FAILED) { uih_error(uih, gettext("File open failed")); return 0; } p = (struct uih_playcontext *) calloc(1, sizeof(*p)); if (p == NULL) { uih_error(uih, gettext("Out of memory")); return 0; } if (animr) { uih->menuroot = animroot; uih_updatemenus(uih, NULL); } p->file = f; p->playframe = 1; p->timer = tl_create_timer(); p->frametime = 0; p->morph = 0; p->morphjulia = 0; p->lines.first = NULL; p->lines.morphing = 0; p->lines.currkey = 0; tl_update_time(); tl_set_handler(p->timer, handler, uih); uih_stoptimers(uih); if (uih->stoppedtimers) tl_stop_timer(p->timer); uih->playc = p; uih->play = 1; uih_emulatetimers(uih); tl_reset_timer(p->timer); uih->playc->line = 1; if (filename != NULL) { uih->playc->directory = xio_getdirectory(filename); } else { uih->playc->directory = xio_getdirectory(XIO_EMPTYPATH); } uih->playc->level = 0; s = uih->playstring; uih->playstring = NULL; uih_playupdate(uih); uih->playstring = s; return 1; }
false
false
false
false
false
0
calibrate_button_clicked_cb (GtkButton *button, CcWacomPage *page) { int i, calibration[4]; GVariant *variant; int *current; gsize ncal; gint monitor; monitor = gsd_wacom_device_get_display_monitor (page->priv->stylus); if (monitor < 0) { /* The display the tablet should be mapped to could not be located. * This shouldn't happen if the EDID data is good... */ g_critical("Output associated with the tablet is not connected. Unable to calibrate."); return; } variant = g_settings_get_value (page->priv->wacom_settings, "area"); current = (int *) g_variant_get_fixed_array (variant, &ncal, sizeof (gint32)); if (ncal != 4) { g_warning("Device calibration property has wrong length. Got %"G_GSIZE_FORMAT" items; expected %d.\n", ncal, 4); g_free (current); return; } for (i = 0; i < 4; i++) calibration[i] = current[i]; if (calibration[0] == -1 && calibration[1] == -1 && calibration[2] == -1 && calibration[3] == -1) { gint *device_cal; device_cal = gsd_wacom_device_get_area (page->priv->stylus); for (i = 0; i < 4; i++) calibration[i] = device_cal[i]; g_free (device_cal); } run_calibration (page, calibration, monitor); gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE); }
false
false
false
false
false
0
add_index_file(const char *path, unsigned mode, void *buf, unsigned long size) { struct stat st; struct cache_entry *ce; int namelen = strlen(path); unsigned ce_size = cache_entry_size(namelen); if (!update_index) return; ce = xcalloc(1, ce_size); memcpy(ce->name, path, namelen); ce->ce_mode = create_ce_mode(mode); ce->ce_flags = htons(namelen); if (!cached) { if (lstat(path, &st) < 0) die("unable to stat newly created file %s", path); fill_stat_cache_info(ce, &st); } if (write_sha1_file(buf, size, blob_type, ce->sha1) < 0) die("unable to create backing store for newly created file %s", path); if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0) die("unable to add cache entry for %s", path); }
false
false
false
false
false
0
Sop_rgb18_Kto_Dacc( GenefxState *gfxs ) { int w = gfxs->length; GenefxAccumulator *D = gfxs->Dacc; u8 *S = gfxs->Sop[0]; u32 Skey = gfxs->Skey; while (w--) { u8 s0 = S[0]; u8 s1 = S[1]; u8 s2 = S[2]; if (Skey != ((u32)(s2<<16 | s1<<8 | s0) & 0x3ffff)) { u8 b = s0 & 0x3F; u8 g = ((s0 & 0xC0) >> 6) | ((s1 & 0x0F) << 2); u8 r = ((s1 & 0xF0) >> 4) | ((s2 & 0x03) << 4); D->RGB.a = 0xFF; D->RGB.r = EXPAND_6to8( r ); D->RGB.g = EXPAND_6to8( g ); D->RGB.b = EXPAND_6to8( b ); } else D->RGB.a = 0xF000; S += 3; D++; } }
false
false
false
false
false
0
rv34_pred_b_vector(int A[2], int B[2], int C[2], int A_avail, int B_avail, int C_avail, int *mx, int *my) { if(A_avail + B_avail + C_avail != 3){ *mx = A[0] + B[0] + C[0]; *my = A[1] + B[1] + C[1]; if(A_avail + B_avail + C_avail == 2){ *mx /= 2; *my /= 2; } }else{ *mx = mid_pred(A[0], B[0], C[0]); *my = mid_pred(A[1], B[1], C[1]); } }
false
false
false
false
false
0
SelectSectionForGlobal( const GlobalValue *GV, SectionKind Kind, Mangler &Mang, const TargetMachine &TM) const { checkMachOComdat(GV); // Handle thread local data. if (Kind.isThreadBSS()) return TLSBSSSection; if (Kind.isThreadData()) return TLSDataSection; if (Kind.isText()) return GV->isWeakForLinker() ? TextCoalSection : TextSection; // If this is weak/linkonce, put this in a coalescable section, either in text // or data depending on if it is writable. if (GV->isWeakForLinker()) { if (Kind.isReadOnly()) return ConstTextCoalSection; return DataCoalSection; } // FIXME: Alignment check should be handled by section classifier. if (Kind.isMergeable1ByteCString() && GV->getParent()->getDataLayout().getPreferredAlignment( cast<GlobalVariable>(GV)) < 32) return CStringSection; // Do not put 16-bit arrays in the UString section if they have an // externally visible label, this runs into issues with certain linker // versions. if (Kind.isMergeable2ByteCString() && !GV->hasExternalLinkage() && GV->getParent()->getDataLayout().getPreferredAlignment( cast<GlobalVariable>(GV)) < 32) return UStringSection; // With MachO only variables whose corresponding symbol starts with 'l' or // 'L' can be merged, so we only try merging GVs with private linkage. if (GV->hasPrivateLinkage() && Kind.isMergeableConst()) { if (Kind.isMergeableConst4()) return FourByteConstantSection; if (Kind.isMergeableConst8()) return EightByteConstantSection; if (Kind.isMergeableConst16()) return SixteenByteConstantSection; } // Otherwise, if it is readonly, but not something we can specially optimize, // just drop it in .const. if (Kind.isReadOnly()) return ReadOnlySection; // If this is marked const, put it into a const section. But if the dynamic // linker needs to write to it, put it in the data segment. if (Kind.isReadOnlyWithRel()) return ConstDataSection; // Put zero initialized globals with strong external linkage in the // DATA, __common section with the .zerofill directive. if (Kind.isBSSExtern()) return DataCommonSection; // Put zero initialized globals with local linkage in __DATA,__bss directive // with the .zerofill directive (aka .lcomm). if (Kind.isBSSLocal()) return DataBSSSection; // Otherwise, just drop the variable in the normal data section. return DataSection; }
false
false
false
false
false
0
b43legacy_write_initvals(struct b43legacy_wldev *dev, const struct b43legacy_iv *ivals, size_t count, size_t array_size) { const struct b43legacy_iv *iv; u16 offset; size_t i; bool bit32; BUILD_BUG_ON(sizeof(struct b43legacy_iv) != 6); iv = ivals; for (i = 0; i < count; i++) { if (array_size < sizeof(iv->offset_size)) goto err_format; array_size -= sizeof(iv->offset_size); offset = be16_to_cpu(iv->offset_size); bit32 = !!(offset & B43legacy_IV_32BIT); offset &= B43legacy_IV_OFFSET_MASK; if (offset >= 0x1000) goto err_format; if (bit32) { u32 value; if (array_size < sizeof(iv->data.d32)) goto err_format; array_size -= sizeof(iv->data.d32); value = get_unaligned_be32(&iv->data.d32); b43legacy_write32(dev, offset, value); iv = (const struct b43legacy_iv *)((const uint8_t *)iv + sizeof(__be16) + sizeof(__be32)); } else { u16 value; if (array_size < sizeof(iv->data.d16)) goto err_format; array_size -= sizeof(iv->data.d16); value = be16_to_cpu(iv->data.d16); b43legacy_write16(dev, offset, value); iv = (const struct b43legacy_iv *)((const uint8_t *)iv + sizeof(__be16) + sizeof(__be16)); } } if (array_size) goto err_format; return 0; err_format: b43legacyerr(dev->wl, "Initial Values Firmware file-format error.\n"); b43legacy_print_fw_helptext(dev->wl); return -EPROTO; }
false
false
false
false
false
0
_ar_card_theme_info_collate (const ArCardThemeInfo *a, const ArCardThemeInfo *b) { g_return_val_if_fail (a != NULL && b != NULL, 0); if (a->type != b->type) return theme_type_compare (a->type, b->type); return g_utf8_collate (a->display_name, b->display_name); }
false
false
false
false
false
0
gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) { struct gfs2_sbd *sdp = rgd->rd_sbd; struct gfs2_bitmap *bi = NULL; u32 length = rgd->rd_length; u32 count[4], tmp; int buf, x; memset(count, 0, 4 * sizeof(u32)); /* Count # blocks in each of 4 possible allocation states */ for (buf = 0; buf < length; buf++) { bi = rgd->rd_bits + buf; for (x = 0; x < 4; x++) count[x] += gfs2_bitcount(rgd, bi->bi_bh->b_data + bi->bi_offset, bi->bi_len, x); } if (count[0] != rgd->rd_free) { if (gfs2_consist_rgrpd(rgd)) fs_err(sdp, "free data mismatch: %u != %u\n", count[0], rgd->rd_free); return; } tmp = rgd->rd_data - rgd->rd_free - rgd->rd_dinodes; if (count[1] != tmp) { if (gfs2_consist_rgrpd(rgd)) fs_err(sdp, "used data mismatch: %u != %u\n", count[1], tmp); return; } if (count[2] + count[3] != rgd->rd_dinodes) { if (gfs2_consist_rgrpd(rgd)) fs_err(sdp, "used metadata mismatch: %u != %u\n", count[2] + count[3], rgd->rd_dinodes); return; } }
false
false
false
false
false
0
track_get_export_filename(Track *track, GError **error) { gchar *res_utf8, *res_cs = NULL; gchar *template; gboolean special_charset; g_return_val_if_fail (track, NULL); prefs_get_string_value(EXPORT_FILES_TPL, &template); res_utf8 = get_string_from_full_template(track, template, TRUE, error); C_FREE (template); prefs_get_int_value(EXPORT_FILES_SPECIAL_CHARSET, &special_charset); /* convert it to the charset */ if (special_charset) { /* use the specified charset */ res_cs = charset_from_utf8(res_utf8); } else { /* use the charset stored in track->charset */ res_cs = charset_track_charset_from_utf8(track, res_utf8); } g_free(res_utf8); return res_cs; }
false
false
false
false
false
0
update_user(XMPP_SERVER_REC *server, const char *jid, const char *subscription, const char *name, const char *group_name) { XMPP_ROSTER_GROUP_REC *group; XMPP_ROSTER_USER_REC *user; g_return_if_fail(IS_XMPP_SERVER(server)); g_return_if_fail(jid != NULL); user = rosters_find_user(server->roster, jid, &group, NULL); if (user == NULL) user = add_user(server, jid, name, group_name, &group); else { /* move to another group and sort it */ if ((group->name == NULL && group_name != NULL) || (group->name != NULL && group_name == NULL) || (group->name != NULL && group_name != NULL && strcmp(group->name, group_name) != 0)) { group = move_user(server, user, group, group_name); group->users = g_slist_sort(group->users, func_sort_user); } /* change name */ if ((user->name == NULL && name != NULL) || (user->name != NULL && name == NULL) || (user->name != NULL && name != NULL && strcmp(user->name, name) != 0)) { g_free(user->name); user->name = g_strdup(name); group->users = g_slist_sort(group->users, func_sort_user); } } update_subscription(server, user, group, subscription); }
false
false
false
false
false
0
ml_gdome_pi_of_n(value obj) { CAMLparam1(obj); GdomeException exc_; GdomeProcessingInstruction* obj_; obj_ = gdome_cast_pi((GdomeNode*) Node_val(obj)); if (obj_ == 0) throw_cast_exception("ProcessingInstruction"); gdome_pi_ref(obj_, &exc_); if (exc_ != 0) throw_exception(exc_, "ProcessingInstruction casting from Node"); CAMLreturn(Val_ProcessingInstruction(obj_)); }
false
false
false
false
false
0
Curl_do_more(struct connectdata *conn, int *complete) { CURLcode result=CURLE_OK; *complete = 0; if(conn->handler->do_more) result = conn->handler->do_more(conn, complete); if(!result && (*complete == 1)) /* do_complete must be called after the protocol-specific DO function */ do_complete(conn); return result; }
false
false
false
false
false
0
canvas_properties(t_glist *x) { t_gobj *y; char graphbuf[200]; if (glist_isgraph(x) != 0) sprintf(graphbuf, "pdtk_canvas_dialog %%s %g %g %d %g %g %g %g %d %d %d %d\n", 0., 0., glist_isgraph(x) ,//1, x->gl_x1, x->gl_y1, x->gl_x2, x->gl_y2, (int)x->gl_pixwidth, (int)x->gl_pixheight, (int)x->gl_xmargin, (int)x->gl_ymargin); else sprintf(graphbuf, "pdtk_canvas_dialog %%s %g %g %d %g %g %g %g %d %d %d %d\n", glist_dpixtodx(x, 1), -glist_dpixtody(x, 1), 0, 0., -1., 1., 1., (int)x->gl_pixwidth, (int)x->gl_pixheight, (int)x->gl_xmargin, (int)x->gl_ymargin); gfxstub_new(&x->gl_pd, x, graphbuf); /* if any arrays are in the graph, put out their dialogs too */ for (y = x->gl_list; y; y = y->g_next) if (pd_class(&y->g_pd) == garray_class) garray_properties((t_garray *)y); }
false
false
false
false
false
0
check_context(char cmd) { // A context is defined to be "modifying text" // Any modifying command establishes a new context. if (dot < context_start || dot > context_end) { if (strchr(modifying_cmds, cmd) != NULL) { // we are trying to modify text[]- make this the current context mark[27] = mark[26]; // move cur to prev mark[26] = dot; // move local to cur context_start = prev_line(prev_line(dot)); context_end = next_line(next_line(dot)); //loiter= start_loiter= now; } } }
false
false
false
false
false
0
oc_enc_fdct8x8_c(ogg_int16_t _y[64],const ogg_int16_t _x[64]){ const ogg_int16_t *in; ogg_int16_t *end; ogg_int16_t *out; ogg_int16_t w[64]; int i; /*Add two extra bits of working precision to improve accuracy; any more and we could overflow.*/ for(i=0;i<64;i++)w[i]=_x[i]<<2; /*These biases correct for some systematic error that remains in the full fDCT->iDCT round trip.*/ w[0]+=(w[0]!=0)+1; w[1]++; w[8]--; /*Transform columns of w into rows of _y.*/ for(in=w,out=_y,end=out+64;out<end;in++,out+=8)oc_fdct8(out,in); /*Transform columns of _y into rows of w.*/ for(in=_y,out=w,end=out+64;out<end;in++,out+=8)oc_fdct8(out,in); /*Round the result back to the external working precision (which is still scaled by four relative to the orthogonal result). TODO: We should just update the external working precision.*/ for(i=0;i<64;i++)_y[i]=w[i]+2>>2; }
true
true
false
false
false
1
printdocCodeSlices(const string& code, ostream& docout) { if ( ! code.empty() ) { docout << endl << "\\begin{lstlisting}[numbers=none, frame=none, basicstyle=\\small\\ttfamily, backgroundcolor=\\color{yobg}]" << endl; docout << code << endl; docout << "\\end{lstlisting}" << endl << endl; } }
false
false
false
false
false
0
SetDataArraySelections(vtkXMLDataElement* eDSA, vtkDataArraySelection* sel) { if(!eDSA) { sel->SetArrays(0, 0); return; } int numArrays = eDSA->GetNumberOfNestedElements(); if(!numArrays) { sel->SetArrays(0, 0); return; } for(int i=0;i < numArrays;++i) { vtkXMLDataElement* eNested = eDSA->GetNestedElement(i); const char* name = eNested->GetAttribute("Name"); if(name) { sel->AddArray( name ); } else { vtksys_ios::ostringstream ostr_with_warning_C4701; ostr_with_warning_C4701 << "Array " << i; sel->AddArray( ostr_with_warning_C4701.str().c_str() ); } } }
false
false
false
false
false
0
ario_shell_similarartists_lastfm_cb (GtkButton *button, ArioShellSimilarartists *shell_similarartists) { ARIO_LOG_FUNCTION_START; GtkTreeModel *treemodel; GtkTreeIter iter; gchar *url; /* Get selected row */ if (gtk_tree_selection_get_selected (shell_similarartists->priv->selection, &treemodel, &iter)) { /* Get URL of selected row */ gtk_tree_model_get (treemodel, &iter, URL_COLUMN, &url, -1); /* Open last.fm URL in web browser */ ario_util_load_uri (url); g_free (url); } }
false
false
false
false
false
0
ReadMolecule(OBBase* pOb, OBConversion* pConv) { OBMol* pmol = pOb->CastAndClear<OBMol>(); if (!pmol) return false; // get the input stream istream& ifs = *pConv->GetInStream(); // read the smiles string std::string smiles; std::getline(ifs, smiles); // extract title std::size_t space_pos = smiles.find(" "); std::size_t tab_pos = smiles.find("\t"); if (space_pos != std::string::npos && tab_pos != std::string::npos) space_pos = std::min(space_pos, tab_pos); else if (tab_pos != std::string::npos) space_pos = tab_pos; if (space_pos != std::string::npos) { while (space_pos < smiles.size() && (smiles[space_pos] == ' ' || smiles[space_pos] == '\t')) ++space_pos; pmol->SetTitle(smiles.substr(space_pos).c_str()); } pmol->BeginModify(); pmol->SetDimension(0); // create callback and parser object OpenBabelCallback callback(pmol); Smiley::Parser<OpenBabelCallback> parser(callback); try { parser.parse(smiles); } catch (Smiley::Exception &e) { if (e.type() == Smiley::Exception::SyntaxError) std::cerr << "Syntax"; else std::cerr << "Semantics"; std::cerr << "Error: " << e.what() << "." << std::endl; std::cerr << smiles << std::endl; for (std::size_t i = 0; i < e.pos(); ++i) std::cerr << " "; for (std::size_t i = 0; i < e.length(); ++i) std::cerr << "^"; std::cerr << std::endl; } pmol->EndModify(); // handle aromaticity pmol->SetAromaticPerceived(); OBAtomTyper typer; typer.AssignImplicitValence(*pmol); // fix aromatic nitrogens FOR_ATOMS_OF_MOL (atom, pmol) { if (atom->IsNitrogen() && atom->IsAromatic() && /*atom->IsInRingSize(6) &&*/ atom->GetValence() == 2) atom->SetImplicitValence(2); } // create cis/trans stereo objects CreateCisTrans(pmol, callback.upDown); StereoFrom0D(pmol); return true; }
false
false
false
false
false
0
compare(ContactListItem *it1, ContactListItem *it2) const { // Contacts ContactListContact* it1_contact = dynamic_cast<ContactListContact*>(it1); ContactListContact* it2_contact = dynamic_cast<ContactListContact*>(it2); if (it1_contact && it2_contact) { if (it1_contact->name() < it2_contact->name()) { return -1; } else if (it1_contact->name() > it2_contact->name()) { return 1; } else { return 0; } } else if (it1_contact) { return -1; } else if (it2_contact) { return 1; } // Groups ContactListGroup* it1_group = dynamic_cast<ContactListGroup*>(it1); ContactListGroup* it2_group = dynamic_cast<ContactListGroup*>(it2); if (it1_group && it2_group) { if (it1_group->name() < it2_group->name()) { return -1; } else if (it1_group->name() > it2_group->name()) { return 1; } else { return 0; } } else if (it1_group) { return -1; } else if (it2_group) { return 1; } return 0; }
false
false
false
false
false
0
ivtv_api_get_data(struct ivtv_mailbox_data *mbdata, int mb, int argc, u32 data[]) { volatile u32 __iomem *p = mbdata->mbox[mb].data; int i; for (i = 0; i < argc; i++, p++) data[i] = readl(p); }
false
false
false
false
false
0
_dxfinit_convert(double gamma) { static double convert_gamma = 0.0; /* current gamma loaded into table */ union hl f; int c, i; if (gamma==convert_gamma) /* already computed? */ return; f.f = 1.0; /* start at pixel value 1.0 */ i = UNSIGN(f.hl.hi); /* unsigned index */ memset(_dxd_convert+i, 255, NC-i); /* set high values to 255 */ do { /* loop through lower values */ f.hl.hi--; /* go to next smaller number */ c = pow(f.f, 1.0/gamma)*255.0; /* f.f converts to c */ _dxd_convert[UNSIGN(f.hl.hi)] = c; /* put conversion in table */ } while (c!=0); /* stop when we get to 0 */ convert_gamma = gamma; /* record the current gamma value */ DXMarkTimeLocal("init convert"); }
false
false
false
false
false
0
_cb_apps_list_selected(void *data) { E_Config_App_List *apps; const E_Ilist_Item *it; const Eina_List *l; unsigned int enabled = 0, disabled = 0; if (!(apps = data)) return; EINA_LIST_FOREACH(e_widget_ilist_items_get(apps->o_list), l, it) { if ((!it->selected) || (it->header)) continue; if (eina_list_search_unsorted(apps->cfdata->apps, _cb_desks_name, it->label)) enabled++; else disabled++; } if (apps->o_desc) { Efreet_Desktop *desk; int sel; sel = e_widget_ilist_selected_get(apps->o_list); desk = eina_list_nth(apps->desks, sel); if (desk) e_widget_textblock_markup_set(apps->o_desc, desk->comment); } e_widget_disabled_set(apps->o_add, !disabled); e_widget_disabled_set(apps->o_del, !enabled); }
false
false
false
false
false
0
xhtml_gensumlineb(FILE *outf, Outchoices *od, int namecode, double x, double x7, logical isaverage) { char **lngstr = od->lngstr; unsigned int bm; char *c; fprintf(outf, "<br /><span class=\"%sgensumtitle\">%s%s</span> ", od->cssprefix, lngstr[namecode], lngstr[colon_]); bm = (od->rawbytes)?0:findbmult(x, od->bytesdp); printbytes(outf, od, x, bm, 0, od->sepchar); if (bm > 0) { c = strchr(lngstr[xbytes_], '?'); *c = '\0'; fprintf(outf, " %s%s%s", lngstr[xbytes_], lngstr[byteprefix_ + bm], c + 1); *c = '?'; } else fprintf(outf, " %s", lngstr[bytes_]); if (x7 != UNSET) { fputs(" (", outf); bm = (od->rawbytes)?0:findbmult(x7, od->bytesdp); printbytes(outf, od, x7, bm, 0, od->sepchar); if (bm > 0) { c = strchr(lngstr[xbytes_], '?'); *c = '\0'; fprintf(outf, " %s%s%s)", lngstr[xbytes_], lngstr[byteprefix_ + bm], c + 1); *c = '?'; } else fprintf(outf, " %s)", lngstr[bytes_]); } putc('\n', outf); }
false
false
false
false
false
0
parse_timezone(struct time *time, const char *zone) { long tz; tz = ('0' - zone[1]) * 60 * 60 * 10; tz += ('0' - zone[2]) * 60 * 60; tz += ('0' - zone[3]) * 60 * 10; tz += ('0' - zone[4]) * 60; if (zone[0] == '-') tz = -tz; time->tz = tz; time->sec -= tz; }
false
false
false
false
false
0
list_get_first_node(struct linked_list* list) { list->iterator = list->first; if (list->iterator == NULL) return NULL; return list->iterator; }
false
false
false
false
false
0
gedit_window_key_press_event (GtkWidget *widget, GdkEventKey *event) { static gpointer grand_parent_class = NULL; GtkWindow *window = GTK_WINDOW (widget); gboolean handled = FALSE; if (grand_parent_class == NULL) { grand_parent_class = g_type_class_peek_parent (gedit_window_parent_class); } /* handle focus widget key events */ if (!handled) { handled = gtk_window_propagate_key_event (window, event); } /* handle mnemonics and accelerators */ if (!handled) { handled = gtk_window_activate_key (window, event); } /* Chain up, invokes binding set on window */ if (!handled) { handled = GTK_WIDGET_CLASS (grand_parent_class)->key_press_event (widget, event); } if (!handled) { return gedit_app_process_window_event (GEDIT_APP (g_application_get_default ()), GEDIT_WINDOW (widget), (GdkEvent *)event); } return TRUE; }
false
false
false
false
false
0
reset(unsigned type) { Bit32u i; BX_FD_THIS s.pending_irq = 0; BX_FD_THIS s.reset_sensei = 0; /* no reset result present */ BX_FD_THIS s.main_status_reg = 0; BX_FD_THIS s.status_reg0 = 0; BX_FD_THIS s.status_reg1 = 0; BX_FD_THIS s.status_reg2 = 0; BX_FD_THIS s.status_reg3 = 0; // software reset (via DOR port 0x3f2 bit 2) does not change DOR if (type == BX_RESET_HARDWARE) { BX_FD_THIS s.DOR = 0x0c; // motor off, drive 3..0 // DMA/INT enabled // normal operation // drive select 0 // DIR and CCR affected only by hard reset for (i=0; i<4; i++) { BX_FD_THIS s.DIR[i] |= 0x80; // disk changed } BX_FD_THIS s.data_rate = 2; /* 250 Kbps */ BX_FD_THIS s.lock = 0; } else { BX_INFO(("controller reset in software")); } if (BX_FD_THIS s.lock == 0) { BX_FD_THIS s.config = 0; BX_FD_THIS s.pretrk = 0; } BX_FD_THIS s.perp_mode = 0; for (i=0; i<4; i++) { BX_FD_THIS s.cylinder[i] = 0; BX_FD_THIS s.head[i] = 0; BX_FD_THIS s.sector[i] = 0; BX_FD_THIS s.eot[i] = 0; } DEV_pic_lower_irq(6); if (!(BX_FD_THIS s.main_status_reg & FD_MS_NDMA)) { DEV_dma_set_drq(FLOPPY_DMA_CHAN, 0); } enter_idle_phase(); }
false
false
false
false
false
0
main(int argc, char **argv) { char *temp, *s; /* Save our program name - for error messages */ temp = argv[0]; s=strrchr(argv[0], '/'); if (s != NULL) temp = s + 1; MyName = safemalloc(strlen(temp)+2); strcpy(MyName,"*"); strcat(MyName, temp); if((argc != 6)&&(argc != 7)) { fprintf(stderr,"%s Version %s should only be executed by fvwm!\n",MyName, VERSION); exit(1); } /* Dead pipe == Fvwm died */ signal (SIGPIPE, DeadPipe); fd[0] = atoi(argv[1]); fd[1] = atoi(argv[2]); /* Data passed in command line */ fprintf(stderr,"Application Window 0x%s\n",argv[4]); fprintf(stderr,"Application Context %s\n",argv[5]); fd_width = GetFdWidth(); /* Create a list of all windows */ /* Request a list of all windows, * wait for ConfigureWindow packets */ SendInfo(fd,"Send_WindowList",0); Loop(fd); return 0; }
false
true
false
false
true
1
ComputeStoreInterceptor( String* name, JSObject* receiver, StrictModeFlag strict_mode) { Code::Flags flags = Code::ComputeMonomorphicFlags( Code::STORE_IC, INTERCEPTOR, strict_mode); Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { StoreStubCompiler compiler(strict_mode); { MaybeObject* maybe_code = compiler.CompileStoreInterceptor(receiver, name); if (!maybe_code->ToObject(&code)) return maybe_code; } PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); Object* result; { MaybeObject* maybe_result = receiver->UpdateMapCodeCache(name, Code::cast(code)); if (!maybe_result->ToObject(&result)) return maybe_result; } } return code; }
false
false
false
false
false
0
position_rect_manipulators() { if(!m_rect) return; //Note that this only works after the child has been added to the canvas: //Goocanvas::Bounds bounds; //m_child->get_bounds(bounds); double x1 = 0; double y1 = 0; get_xy(x1, y1); double child_x = 0; double child_y = 0; get_xy(child_x, child_y); //TODO: Remove duplicate get_xy() call? //std::cout << "debug: " << G_STRFUNC << ": child x=" << child_x << std::endl; double child_width = 0; double child_height = 0; get_width_height(child_width, child_height); //std::cout << "debug: " << G_STRFUNC << ": child width=" << child_width << std::endl; //Show the size of this item (not always the same as the child size): m_rect->property_x() = child_x; m_rect->property_y() = child_y; m_rect->property_width() = child_width; m_rect->property_height() = child_height; //m_rect->property_fill_color_rgba() = 0xFFFFFF00; const double x2 = child_x + child_width; const double y2 = child_y + child_height; Glib::RefPtr<Goocanvas::Item> item = CanvasItemMovable::cast_to_item(m_child); m_manipulator_corner_top_left->set_xy(x1, y1); m_manipulator_corner_top_right->set_xy(x2 - MANIPULATOR_CORNER_SIZE, y1); m_manipulator_corner_bottom_left->set_xy(x1, y2 - MANIPULATOR_CORNER_SIZE); m_manipulator_corner_bottom_right->set_xy(x2 - MANIPULATOR_CORNER_SIZE, y2 - MANIPULATOR_CORNER_SIZE); set_edge_points(m_manipulator_edge_top, x1, y1, x2, y1); set_edge_points(m_manipulator_edge_bottom, x1, y2, x2, y2); set_edge_points(m_manipulator_edge_left, x1, y1, x1, y2); set_edge_points(m_manipulator_edge_right, x2, y1, x2, y2); //Make sure that the bounds rect is below the item, //and the manipulators are above the item (and above the rect): if(item) { m_group_edge_manipulators->raise(); m_group_corner_manipulators->raise(); m_rect->lower(item); } else { m_group_edge_manipulators->raise(); m_group_corner_manipulators->raise(); } }
false
false
false
false
false
0
xsh_prepare( cpl_frameset* frames, cpl_frame * bpmap, cpl_frame* mbias, const char* prefix, xsh_instrument* instr, const int pre_overscan_corr,const bool flag_neg_and_thresh_pix) { xsh_pre* pre = NULL; cpl_frame *current = NULL; cpl_frame* product = NULL; xsh_pre* bias = NULL; cpl_image* bias_data = NULL; char result_name[256]; char result_tag[256]; int i,size; /* check input parameters */ XSH_ASSURE_NOT_NULL( frames); XSH_ASSURE_NOT_NULL( prefix); XSH_ASSURE_NOT_NULL( instr); check( size = cpl_frameset_get_size( frames) ); // Special for unitary tests (without master bias frame) if ( mbias == (cpl_frame *)-1 ) { bias_data = (cpl_image *)-1 ; } else if ( mbias != NULL ) { /* load data */ check( bias = xsh_pre_load( mbias, instr)); check( bias_data = xsh_pre_get_data( bias)); } else if ( mbias == NULL ) { bias_data = (cpl_image *)-1 ; } for( i=0; i<size; i++ ) { check( current = cpl_frameset_get_frame( frames, i)); xsh_msg_dbg_medium("Load frame %s", cpl_frame_get_filename( current)); check( pre = xsh_pre_create( current, bpmap, bias_data, instr, pre_overscan_corr,flag_neg_and_thresh_pix)); /* save result */ if(strcmp(prefix,XSH_FLAT)==0) { if(xsh_instrument_get_lamp(instr)==XSH_LAMP_QTH) { sprintf( result_name, "%s_QTH_PRE_%d.fits", prefix, i); } else if(xsh_instrument_get_lamp(instr)==XSH_LAMP_D2) { sprintf( result_name, "%s_D2_PRE_%d.fits", prefix, i); } else { sprintf( result_name, "%s_PRE_%d.fits", prefix, i); } } else { sprintf( result_name, "%s_PRE_%d.fits", prefix, i); } sprintf( result_tag, "%s_PRE_%d", prefix, i); xsh_msg_dbg_medium( "Save frame %s", result_name); check( product = xsh_pre_save( pre, result_name,result_tag,1 )); xsh_pre_free( &pre); /* update the frame */ check( cpl_frame_set_filename( current, cpl_frame_get_filename( product) ) ); check( cpl_frame_set_type( current, cpl_frame_get_type( product))); check( cpl_frame_set_level( current, cpl_frame_get_level( product))); xsh_free_frame( &product); } cleanup: if( cpl_error_get_code() != CPL_ERROR_NONE) { xsh_pre_free( &pre); xsh_free_frame( &product); } xsh_pre_free( &bias); return; }
false
false
false
false
false
0
gen_neon_vset_lanev2di (rtx operand0, rtx operand1, rtx operand2, rtx operand3) { rtx _val = 0; start_sequence (); { rtx operands[4]; operands[0] = operand0; operands[1] = operand1; operands[2] = operand2; operands[3] = operand3; #line 3065 "../../src/gcc/config/arm/neon.md" { unsigned int elt = INTVAL (operands[3]); neon_lane_bounds (operands[3], 0, GET_MODE_NUNITS (V2DImode)); if (BYTES_BIG_ENDIAN) { unsigned int reg_nelts = 64 / GET_MODE_BITSIZE (GET_MODE_INNER (V2DImode)); elt ^= reg_nelts - 1; } emit_insn (gen_vec_setv2di_internal (operands[0], operands[1], GEN_INT (1 << elt), operands[2])); DONE; } operand0 = operands[0]; (void) operand0; operand1 = operands[1]; (void) operand1; operand2 = operands[2]; (void) operand2; operand3 = operands[3]; (void) operand3; } emit (operand0); emit (operand1); emit (operand2); emit (operand3); _val = get_insns (); end_sequence (); return _val; }
false
false
false
false
false
0
nn_TemporalConvolution_forward(lua_State *L) { THTensor *input = luaT_checkudata(L, 2, torch_Tensor_id); int kW = luaT_getfieldcheckint(L, 1, "kW"); int dW = luaT_getfieldcheckint(L, 1, "dW"); int inputFrameSize = luaT_getfieldcheckint(L, 1, "inputFrameSize"); int outputFrameSize = luaT_getfieldcheckint(L, 1, "outputFrameSize"); THTensor *weight = luaT_getfieldcheckudata(L, 1, "weight", torch_Tensor_id); THTensor *bias = luaT_getfieldcheckudata(L, 1, "bias", torch_Tensor_id); THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor_id); THTensor *outputFrame, *unfoldedInput, *unfoldedInputFrame, *xWeight; int nInputFrame, nOutputFrame; int k; luaL_argcheck(L, input->nDimension == 2, 2, "2D tensor expected"); luaL_argcheck(L, input->size[0] == inputFrameSize, 2, "invalid input frame size"); luaL_argcheck(L, input->size[1] >= kW, 2, "input sequence smaller than kernel size"); nInputFrame = input->size[1]; nOutputFrame = (nInputFrame - kW) / dW + 1; THTensor_resize2d(output, outputFrameSize, nOutputFrame); xWeight = THTensor_new(); outputFrame = THTensor_new(); unfoldedInput = THTensor_new(); unfoldedInputFrame = THTensor_new(); THTensor_unfold(unfoldedInput, input, 1, kW, dW); THTensor_setStorage4d(xWeight, weight->storage, weight->storageOffset, weight->size[0], weight->stride[0], weight->size[1], weight->stride[1], weight->size[2], weight->stride[2], 1, -1); THTensor_transpose(xWeight,NULL,0,2); THTensor_transpose(xWeight,NULL,1,3); for(k = 0; k < nOutputFrame; k++) { THTensor_select(unfoldedInputFrame, unfoldedInput, 1, k); THTensor_narrow(outputFrame, output, 1, k, 1); THTensor_copy(outputFrame, bias); THTensor_addT4dotT2(outputFrame, 1, xWeight, unfoldedInputFrame); } THTensor_free(xWeight); THTensor_free(outputFrame); THTensor_free(unfoldedInput); THTensor_free(unfoldedInputFrame); return 1; }
false
false
false
false
false
0
gridfile_read_buffer( gridfile *gfile, char *buf, gridfs_offset size ) { mongo_cursor *chunks; int first_chunk; int total_chunks; gridfs_offset chunksize; gridfs_offset contentlength; gridfs_offset bytes_left; gridfs_offset realSize = 0; contentlength = gridfile_get_contentlength(gfile); chunksize = gridfile_get_chunksize(gfile); size = MIN( contentlength - gfile->pos, size ); bytes_left = size; first_chunk = (int)((gfile->pos) / chunksize); total_chunks = (int)((gfile->pos + size - 1) / chunksize) - first_chunk + 1; if( (realSize = gridfile_read_from_pending_buffer( gfile, bytes_left, buf, &first_chunk )) > 0 ) { gfile->pos += realSize; if( --total_chunks <= 0) { return realSize; } buf += realSize; bytes_left -= realSize; if( gridfile_flush_pendingchunk( gfile ) != MONGO_OK ){ /* Let's abort the read operation here because we could not flush the buffer */ return realSize; } }; chunks = gridfile_get_chunks(gfile, first_chunk, total_chunks); realSize += gridfile_load_from_chunks( gfile, total_chunks, chunksize, chunks, buf, bytes_left); mongo_cursor_destroy(chunks); gfile->pos += realSize; return realSize; }
false
false
false
false
false
0
_GD_OldTypeName(DIRFILE* D, gd_type_t data_type) { const char* ptr; dtrace("%p, 0x%x", D, data_type); switch(data_type) { case GD_UINT8: ptr = "c"; break; case GD_UINT16: ptr = "u"; break; case GD_INT16: ptr = "s"; break; case GD_UINT32: ptr = "U"; break; case GD_INT32: ptr = "S"; break; case GD_FLOAT32: ptr = "f"; break; case GD_FLOAT64: ptr = "d"; break; default: _GD_InternalError(D); ptr = ""; break; } dreturn("\"%s\"", ptr); return ptr; }
false
false
false
false
false
0
mbfl_filt_ident_koi8r(int c, mbfl_identify_filter *filter) { if (c >= 0x80 && c < 0xff) filter->flag = 0; else filter->flag = 1; /* not it */ return c; }
false
false
false
false
false
0
fm_modules_load(void) { if (!g_atomic_int_compare_and_exchange(&fm_modules_loaded, 0, 1)) return; fm_run_in_default_main_context(_fm_modules_load, NULL); }
false
false
false
false
false
0
bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) { int rc = 0; struct bnxt *bp = netdev_priv(dev); struct bnxt_link_info *link_info = &bp->link_info; bool set_pause = false; u16 fw_advertising = 0; u32 speed; if (!BNXT_SINGLE_PF(bp)) return -EOPNOTSUPP; if (cmd->autoneg == AUTONEG_ENABLE) { u32 supported_spds = bnxt_fw_to_ethtool_support_adv_spds(link_info); if (!supported_spds) { netdev_err(dev, "Autoneg not supported\n"); rc = -EINVAL; goto set_setting_exit; } if (cmd->advertising & ~(supported_spds | ADVERTISED_Autoneg | ADVERTISED_TP | ADVERTISED_FIBRE)) { netdev_err(dev, "Unsupported advertising mask (adv: 0x%x)\n", cmd->advertising); rc = -EINVAL; goto set_setting_exit; } fw_advertising = bnxt_get_fw_auto_link_speeds(cmd->advertising); link_info->autoneg |= BNXT_AUTONEG_SPEED; if (!fw_advertising) link_info->advertising = link_info->support_auto_speeds; else link_info->advertising = fw_advertising; /* any change to autoneg will cause link change, therefore the * driver should put back the original pause setting in autoneg */ set_pause = true; } else { u16 fw_speed; u8 phy_type = link_info->phy_type; if (phy_type == PORT_PHY_QCFG_RESP_PHY_TYPE_BASET || phy_type == PORT_PHY_QCFG_RESP_PHY_TYPE_BASETE || link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP) { netdev_err(dev, "10GBase-T devices must autoneg\n"); rc = -EINVAL; goto set_setting_exit; } /* TODO: currently don't support half duplex */ if (cmd->duplex == DUPLEX_HALF) { netdev_err(dev, "HALF DUPLEX is not supported!\n"); rc = -EINVAL; goto set_setting_exit; } /* If received a request for an unknown duplex, assume full*/ if (cmd->duplex == DUPLEX_UNKNOWN) cmd->duplex = DUPLEX_FULL; speed = ethtool_cmd_speed(cmd); fw_speed = bnxt_get_fw_speed(dev, speed); if (!fw_speed) { rc = -EINVAL; goto set_setting_exit; } link_info->req_link_speed = fw_speed; link_info->req_duplex = BNXT_LINK_DUPLEX_FULL; link_info->autoneg = 0; link_info->advertising = 0; } if (netif_running(dev)) rc = bnxt_hwrm_set_link_setting(bp, set_pause, false); set_setting_exit: return rc; }
false
false
false
false
false
0
ks959_suspend(struct usb_interface *intf, pm_message_t message) { struct ks959_cb *kingsun = usb_get_intfdata(intf); netif_device_detach(kingsun->netdev); if (kingsun->speed_urb != NULL) usb_kill_urb(kingsun->speed_urb); if (kingsun->tx_urb != NULL) usb_kill_urb(kingsun->tx_urb); if (kingsun->rx_urb != NULL) usb_kill_urb(kingsun->rx_urb); return 0; }
false
false
false
false
false
0
register_access (CObjectInfo *obj, CTree *node) { // only track attributes if the tracker dog is configured to do it. if (!_track_attrs) return false; // is a relevent attribute accessed? if (!obj || !obj->AttributeInfo () || !obj->Scope () || obj->Scope ()->isLocalScope () || obj->isAnonymous () || (strncmp (obj->QualName (), "JoinPoint::", 11) == 0 || strcmp (obj->Name (), "this") == 0) || strcmp (obj->QualName (), "tjp") == 0) return false; if (last_init_declarator && last_init_declarator->Object () == obj) return false; Unit *unit = (Unit*)node->token ()->belonging_to (); while (unit->isMacroExp ()) unit = ((MacroUnit*)unit)->CallingUnit (); if (!(IntroductionUnit::cast (unit) || db ().Project ()->isBelow (unit))) return false; // register the accessing syntax tree #ifndef ACMODEL // TODO: has to be implemented _jpm.register_attr_access (obj->AttributeInfo (), node); #endif return true; }
false
false
false
false
false
0
stepRemovingDirectories() { if (!m_dirCleanupStack.isEmpty()) { KUrl dir = m_dirCleanupStack.pop(); kDebug(1203) << "rmdir" << dir; m_currentJob = KIO::rmdir(dir); m_undoJob->emitDeleting(dir); addDirToUpdate(dir); } else { m_current.m_valid = false; m_currentJob = 0; if (m_undoJob) { kDebug(1203) << "deleting undojob"; m_undoJob->emitResult(); m_undoJob = 0; } QList<KUrl>::ConstIterator it = m_dirsToUpdate.constBegin(); for(; it != m_dirsToUpdate.constEnd(); ++it) { kDebug() << "Notifying FilesAdded for " << *it; org::kde::KDirNotify::emitFilesAdded((*it).url()); } emit q->undoJobFinished(); broadcastUnlock(); } }
false
false
false
false
false
0
dm_raid0(struct lib_context *lc, char **table, struct raid_set *rs) { unsigned int stripes = 0; uint64_t min, last_min = 0; for (; (min = _smallest(lc, rs, last_min)); last_min = min) { if (last_min && !p_fmt(lc, table, "\n")) goto err; if (!_dm_raid0_bol(lc, table, round_down(min, rs->stride), last_min, _dm_raid_devs(lc, rs, last_min), rs->stride) || !_dm_raid0_eol(lc, table, rs, &stripes, last_min)) goto err; if (!F_MAXIMIZE(rs)) break; } return stripes ? 1 : 0; err: return log_alloc_err(lc, __func__); }
false
false
false
false
false
0
set_palette ( unsigned char *rgbs, // 256 3-byte entries. int maxval, // Highest val. for each color. int brightness // Brightness control (100 = normal). ) { // Get the colors. for (int i = 0; i < 3*256; i += 3) { unsigned char r = Get_color16(rgbs[i], maxval, brightness); unsigned char g = Get_color16(rgbs[i + 1], maxval, brightness); unsigned char b = Get_color16(rgbs[i + 2], maxval, brightness); set_palette_color(i/3, r, g, b); } }
false
false
false
false
false
0
initShellProcess() { if (tty0_fd != -1) close(tty0_fd); FbTerm::instance()->initChildProcess(); if (!firstShell) return; bool verbose = false; Config::instance()->getOption("verbose", verbose); TtyInput::instance()->showInfo(verbose); Screen::instance()->showInfo(verbose); Font::instance()->showInfo(verbose); if (verbose) { printf("[term] size: %dx%d, default codec: %s\n", screen->cols(), screen->rows(), localCodec()); } }
false
false
false
false
false
0
pll_freq_delta(unsigned int f1, unsigned int f2) { if (f2 < f1) { f2 = f1 - f2; } else { f2 = f2 - f1; } return f2; }
false
false
false
false
false
0